Coldfusion string matching bug

Discussion in 'Programming' started by LTumbleweed, Nov 2, 2007.

  1. #1
    Hi,

    I'm reading a list of ISBN's from a text file and using the contents to search against a list of ISBNs in an sql database. Once I have a list of macthes I then subtract those from the list input by the user (To perform another search).

    The problem is that when I delete from the list one value doesnt seem to match even though the values are equivilent, based on extensive testing I can say they are. I have even used a struct and find keys and result is the same. I have used "#val#" eq "#array[x]#" and compare again the result is the same.

    All other values match correctly.

    Has anyone else suffered from this, if so is there a solution. The value is of type char 10 in the DB.
     
    LTumbleweed, Nov 2, 2007 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Difficult to say much without seeing your queries.

    Two common 'gotchas' are forgetting that 'char' fields may be padded with spaces. So 'a ' (with trailing spaces) might not match 'a' (no trailing spaces) . If you're using a QoQ, they are case sensitive so 'a' might not match 'A'.

    You probably know what I'm going to say ;) ... that suggests either a code error or that the values are not truly equal. Check the length of the values in question. Are they equal? If you're using a QoQ or case-sensitive database, check the case of both values. Are they the same? Use the len() and compare() functions.
     
    cfStarlight, Nov 2, 2007 IP