Menu

#6 'in' keyword fails to find strings in array

pending-fixed
nobody
None
5
2012-06-12
2012-05-16
jshvrsn
No

Queries which use the 'in' keyword to match array entries doesn't work with strings, it only finds the first string. I'll attach a file which demos the problem. I'm using FastDB 3.67.

Discussion

  • jshvrsn

    jshvrsn - 2012-05-16

    Demo Code

     
  • jshvrsn

    jshvrsn - 2012-05-17

    I think I found the fix. In database.cpp, change 'base' to 'p' in the strcmp of searchArrayOfString():

    inline void searchArrayOfString(dbSynthesizedAttribute& sattr,
    dbSynthesizedAttribute& sattr2)
    {
    dbVarying *p = (dbVarying*)sattr2.array.base;
    int n = sattr2.array.size;
    char* str = sattr.array.base;
    char* base = (char*)sattr2.base;
    while (--n >= 0) {
    if (strcmp(base + p->offs, str) == 0) {
    sattr.bvalue = true;
    return;
    }
    p += 1;
    }
    sattr.bvalue = false;
    }

    inline void searchArrayOfString(dbSynthesizedAttribute& sattr,
    dbSynthesizedAttribute& sattr2)
    {
    dbVarying *p = (dbVarying*)sattr2.array.base;
    int n = sattr2.array.size;
    char* str = sattr.array.base;
    char* base = (char*)sattr2.base;
    while (--n >= 0) {
    if (strcmp(p+ p->offs, str) == 0) {
    sattr.bvalue = true;
    return;
    }
    p += 1;
    }
    sattr.bvalue = false;
    }

     
  • jshvrsn

    jshvrsn - 2012-06-12

    Fixed in SVN 48.

     
  • jshvrsn

    jshvrsn - 2012-06-12
    • status: open --> pending-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB