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/detselect.c

    r16170 r18561  
    8181
    8282    psMetadata *where = psMetadataAlloc();
     83
     84    PXOPT_COPY_STR(config->args, where, "-inst",      "camera", "==");
     85    PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "==");
     86    PXOPT_COPY_STR(config->args, where, "-det_type",  "det_type", "==");
     87    PXOPT_COPY_STR(config->args, where, "-type",      "det_type", "==");
     88    PXOPT_COPY_STR(config->args, where, "-filter",    "filter", "==");
    8389
    8490    // airmass_min  < airmass  < airmass_max
     
    111117    }
    112118
    113     if (config->where) {
    114         psString whereClause = psDBGenerateWhereConditionSQL(config->where, NULL);
    115         psStringAppend(&query, " AND %s", whereClause);
    116         psFree(whereClause);
    117     }
    118 
    119     {
     119    // use psDBGenerateWhereConditionalSQL with AND ... because the SQL ends in a WHERE
     120    if (where && psListLength(where->list)) {
    120121        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    121         psFree(where);
    122         if (whereClause) {
    123             psStringAppend(&query, " AND %s", whereClause);
    124             psFree(whereClause);
    125         }
    126     }
     122        psStringAppend(&query, " AND %s", whereClause);
     123        psFree(whereClause);
     124    }
     125    psFree(where);
    127126
    128127    // we choose the single detrend image which matches all criteria and has
     
    171170    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    172171
     172    psMetadata *where = psMetadataAlloc();
     173    PXOPT_COPY_STR(config->args, where, "-det_id",    "det_id", "==");
     174    PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "==");
     175    PXOPT_COPY_STR(config->args, where, "-class_id",  "class_id", "==");
     176
    173177    psString query = pxDataGet("detselect_select.sql");
    174178    if (!query) {
     
    177181    }
    178182
    179 
    180     if (config->where) {
    181         psString whereClause = psDBGenerateWhereConditionSQL(config->where, NULL);
     183    // use psDBGenerateWhereConditionalSQL with AND ... because the SQL ends in a WHERE
     184    if (where && psListLength(where->list)) {
     185        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    182186        psStringAppend(&query, " AND %s", whereClause);
    183187        psFree(whereClause);
    184188    }
     189    psFree(where);
    185190
    186191    if (!p_psDBRunQuery(config->dbh, query)) {
Note: See TracChangeset for help on using the changeset viewer.