IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2005, 1:19:46 PM (21 years ago)
Author:
asc
Message:

Add support for AUTO_INCREMENT

File:
1 edited

Legend:

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

    r3957 r3961  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-05-18 00:55:36 $
     14 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-05-18 23:19:46 $
    1616 *
    1717 *  Copyright 2005 Joshua Hoblitt, University of Hawaii
     
    875875            return NULL;
    876876        }
     877        if (strstr(item->comment, "AUTO_INCREMENT")) {
     878            psStringAppend(&query, "%s", " AUTO_INCREMENT");
     879        }
    877880
    878881        // add a , after every column declaration except the last one
     
    886889    // find database indexes
    887890    while ((item = psListGetAndIncrement(cursor))) {
    888         if ((strncmp(item->comment, "Primary Key", strlen("Primary Key"))) == 0) {
     891        // XXX NOTE: check for "Primary Key" first before "Key".  Yes we're
     892        // playing fast and loose here, but I think it's fine...
     893        if (strstr(item->comment, "Primary Key")) {
    889894            psStringAppend(&query, ", PRIMARY KEY(%s)", item->name);
    890         } else if ((strncmp(item->comment, "Key", strlen("Key"))) == 0) {
     895        } else if (strstr(item->comment, "Key")) {
     896            psStringAppend(&query, ", KEY(%s)", item->name);
     897        } else if (strstr(item->comment, "AUTO_INCREMENT")) {
     898            // this needs to be recognized as a key if it wasn't already
    891899            psStringAppend(&query, ", KEY(%s)", item->name);
    892900        }
Note: See TracChangeset for help on using the changeset viewer.