Changeset 9396
- Timestamp:
- Oct 6, 2006, 7:12:33 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/db/psDB.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/db/psDB.c
r9179 r9396 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.9 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-10-0 4 03:16:17$14 * @version $Revision: 1.96 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-10-07 05:12:33 $ 16 16 * 17 17 * Copyright (C) 2005-2006 Joshua Hoblitt, University of Hawaii … … 1635 1635 1636 1636 // if tableName is specified prepend it to the item name 1637 psString itemName = NULL; 1637 1638 if (tableName) { 1638 psStringAppend(&query, "%s.", tableName); 1639 psStringAppend(&itemName, "%s.%s", tableName, itemName); 1640 } else { 1641 psStringAppend(&itemName, "%s", itemName); 1639 1642 } 1640 1643 1641 1644 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)); 1643 1646 } 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); 1645 1648 } 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); 1647 1650 } 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)); 1649 1652 } else if (item->type == PS_DATA_STRING) { 1650 1653 // + column name + _ + like + _ + ' + value + ' 1651 1654 // check for NULL and empty ("") strings 1652 1655 if (item->data.V == NULL || *item->data.str == '\0') { 1653 psStringAppend(&query, "%s IS NULL", item ->name);1656 psStringAppend(&query, "%s IS NULL", itemName); 1654 1657 } else { 1655 1658 if (item->comment && strstr(item->comment, "LIKE")) { … … 1658 1661 // very large TEXT columns that really shouldn't be 1659 1662 // 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); 1661 1664 } else { 1662 psStringAppend(&query, "%s = '%s'", item ->name, item->data.str);1665 psStringAppend(&query, "%s = '%s'", itemName, item->data.str); 1663 1666 } 1664 1667 }
Note:
See TracChangeset
for help on using the changeset viewer.
