IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 6, 2006, 7:12:33 PM (20 years ago)
Author:
jhoblitt
Message:

fix conditonal SQL generation for floating point types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/db/psDB.c

    r9179 r9396  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.95 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-10-04 03:16:17 $
     14 *  @version $Revision: 1.96 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-10-07 05:12:33 $
    1616 *
    1717 *  Copyright (C) 2005-2006  Joshua Hoblitt, University of Hawaii
     
    16351635
    16361636    // if tableName is specified prepend it to the item name
     1637    psString itemName = NULL;
    16371638    if (tableName) {
    1638         psStringAppend(&query, "%s.", tableName);
     1639        psStringAppend(&itemName, "%s.%s", tableName, itemName);
     1640    } else {
     1641        psStringAppend(&itemName, "%s", itemName);
    16391642    }
    16401643
    16411644    if ((item->type == PS_DATA_S32) || (item->type == PS_TYPE_S32)) {
    1642         psStringAppend(&query, "%s=%d", item->name, (int)(item->data.S32));
     1645        psStringAppend(&query, "%s=%d", itemName, (int)(item->data.S32));
    16431646    } else if ((item->type == PS_DATA_F32) || (item->type == PS_TYPE_F32)) {
    1644         psStringAppend(&query, "(ABS(%s - %.8f) < %.8f)", item->name, (float)(item->data.F32), FLT_EPSILON * 10);
     1647        psStringAppend(&query, "(ABS(%s - %.8f) < %.8f)", itemName, (float)(item->data.F32), FLT_EPSILON * 10);
    16451648    } else if ((item->type == PS_DATA_F64) || (item->type == PS_TYPE_F64)) {
    1646         psStringAppend(&query, "(ABS(%s - %.17f) < %.17f)", item->name, (double)(item->data.F64), DBL_EPSILON * 10);
     1649        psStringAppend(&query, "(ABS(%s - %.17f) < %.17f)", itemName, (double)(item->data.F64), DBL_EPSILON * 10);
    16471650    } else if ((item->type == PS_DATA_BOOL) || (item->type == PS_TYPE_BOOL)) {
    1648         psStringAppend(&query, "%s=%d", item->name, (int)(item->data.B));
     1651        psStringAppend(&query, "%s=%d", itemName, (int)(item->data.B));
    16491652    } else if (item->type == PS_DATA_STRING) {
    16501653        // + column name + _ + like + _ + ' + value + '
    16511654        // check for NULL and empty ("") strings
    16521655        if (item->data.V == NULL || *item->data.str == '\0') {
    1653             psStringAppend(&query, "%s IS NULL", item->name);
     1656            psStringAppend(&query, "%s IS NULL", itemName);
    16541657        } else {
    16551658            if (item->comment && strstr(item->comment, "LIKE")) {
     
    16581661                // very large TEXT columns that really shouldn't be
    16591662                // used in a where clause...
    1660                 psStringAppend(&query, "%s LIKE '%s'", item->name, item->data.str);
     1663                psStringAppend(&query, "%s LIKE '%s'", itemName, item->data.str);
    16611664            } else {
    1662                 psStringAppend(&query, "%s = '%s'", item->name, item->data.str);
     1665                psStringAppend(&query, "%s = '%s'", itemName, item->data.str);
    16631666            }
    16641667        }
Note: See TracChangeset for help on using the changeset viewer.