diff options
| author | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-18 01:28:20 +0100 |
|---|---|---|
| committer | David Sommerseth <dazo@users.sourceforge.net> | 2008-12-18 01:28:20 +0100 |
| commit | 7b41f88947712f584b50dc240289ec74eeb26a3e (patch) | |
| tree | 525357232bee4f70508fe39a525c1af04da3d582 /database | |
| parent | f8789b292c8109bf0fb23796e751c34c8d43da66 (diff) | |
| download | eurephia-7b41f88947712f584b50dc240289ec74eeb26a3e.tar.gz eurephia-7b41f88947712f584b50dc240289ec74eeb26a3e.tar.xz eurephia-7b41f88947712f584b50dc240289ec74eeb26a3e.zip | |
eDBxmlMapping(...) did not honor the setnull attribute correctly.
Diffstat (limited to 'database')
| -rw-r--r-- | database/eurephiadb_mapping.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/database/eurephiadb_mapping.c b/database/eurephiadb_mapping.c index 83f1ea2..cd222c7 100644 --- a/database/eurephiadb_mapping.c +++ b/database/eurephiadb_mapping.c @@ -116,7 +116,9 @@ inline void eDBcopyMapAttribs(eDBfieldMap *newmap, eDBfieldMap *dbmap, int field for( i = 0; dbmap[i].field_name != NULL; i++ ) { if( dbmap[i].field_id == field ) { newmap->field_name = dbmap[i].field_name; - newmap->field_type = dbmap[i].field_type; + if( newmap->field_type != ft_SETNULL ) { + newmap->field_type = dbmap[i].field_type; + } } } } @@ -152,12 +154,10 @@ eDBfieldMap *eDBxmlMapping(eurephiaCTX *ctx, eDBfieldMap *dbmap, const char *tbl continue; } - if((nptr->name != NULL) && (nptr->children != NULL)) { + if( nptr->name != NULL ) { int setnull = 0; xmlAttr *atr; - // printf("Field '%s' - Value: '%s'\n", nptr->name, nptr->children->content); - // Check if we have the "setnull" attribute set to "1" for( atr = nptr->properties; atr != NULL; atr = atr->next ) { if( (atr->name != NULL) && (xmlStrcmp(atr->name, (xmlChar *)"setnull") == 0) ) { @@ -176,17 +176,23 @@ eDBfieldMap *eDBxmlMapping(eurephiaCTX *ctx, eDBfieldMap *dbmap, const char *tbl // If flagged for being set to NULL, change the field type ptr->field_type = ft_SETNULL; } - switch( ptr->field_type ) { - case ft_PASSWD: // If it is a password field type, hash the value - ptr->value = passwdhash((char *)nptr->children->content); - break; + switch( ptr->field_type ) { case ft_SETNULL: // Don't set any values if we want to set it to NULL ptr->value = NULL; break; + + case ft_PASSWD: // If it is a password field type, hash the value + ptr->value = (nptr->children != NULL + ? passwdhash((char *)nptr->children->content) + : strdup("")); + break; + default: - ptr->value = strdup_nullsafe((char *)nptr->children->content); + ptr->value = (nptr->children != NULL + ? strdup_nullsafe((char *)nptr->children->content) + : strdup("")); break; } break; @@ -196,7 +202,8 @@ eDBfieldMap *eDBxmlMapping(eurephiaCTX *ctx, eDBfieldMap *dbmap, const char *tbl // Go to next XML node nptr = nptr->next; } else { - printf("*** Illegal XML - unaccepted node: (%i) %s\n", nptr->type, nptr->name); + eurephia_log(ctx, LOG_ERROR, 0, "*** Illegal XML - unaccepted node: (%i) %s\n", + nptr->type, nptr->name); return NULL; } } |
