IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 15, 2008, 10:30:59 AM (18 years ago)
Author:
eugene
Message:

completely deprecate config->where; make all command-line handling consistent; move nearly all sql into share/*.sql; ensure consistency between args supplied and used

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/caltool.c

    r18336 r18561  
    110110
    111111    psString query = psStringCopy("SELECT * FROM calDB");
    112 
    113     if (config->where) {
    114         psString whereClause = psDBGenerateWhereSQL(config->where, NULL);
    115         psStringAppend(&query, " %s", whereClause);
    116         psFree(whereClause);
    117     }
    118112
    119113    // treat limit == 0 as "no limit"
     
    195189    PS_ASSERT_PTR_NON_NULL(config, false);
    196190
     191    psMetadata *where = psMetadataAlloc();
     192    PXOPT_COPY_STR(config->args, where,  "-cal_id",     "cal_id", "==");
     193
    197194    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    198195    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     196    PXOPT_LOOKUP_BOOL(faulted, config->args, "-simple", false);
    199197
    200198    psString query = psStringCopy("SELECT * FROM calRun");
    201199
    202     if (config->where) {
    203         psString whereClause = psDBGenerateWhereSQL(config->where, NULL);
     200    if (faulted) {
     201        // list only faulted rows
     202        psStringAppend(&query, " %s", "WHERE fault != 0");
     203    } else {
     204        // don't list faulted rows
     205        psStringAppend(&query, " %s", "WHERE fault = 0");
     206    }
     207
     208    if (psListLength(where->list)) {
     209        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    204210        psStringAppend(&query, " %s", whereClause);
    205211        psFree(whereClause);
    206212    }
     213    psFree(where);
    207214
    208215    // treat limit == 0 as "no limit"
    209216    if (limit) {
    210217        psString limitString = psDBGenerateLimitSQL(limit);
    211         psStringAppend(&query, " %s", limitString);
     218        psStringAppend(&query, " AND %s", limitString);
    212219        psFree(limitString);
    213220    }
Note: See TracChangeset for help on using the changeset viewer.