Sun, 16 Feb 2025 15:14:45 +0100
add function for registering classes without PK
| dbutils/dbutils.c | file | annotate | diff | comparison | revisions | |
| dbutils/dbutils/dbutils.h | file | annotate | diff | comparison | revisions | |
| dbutils/object.c | file | annotate | diff | comparison | revisions |
--- a/dbutils/dbutils.c Sun Feb 16 09:30:18 2025 +0100 +++ b/dbutils/dbutils.c Sun Feb 16 15:14:45 2025 +0100 @@ -134,3 +134,15 @@ cxMapPut(context->classes, name, cls); return cls; } + +DBUClass* dbuRegisterClassWithoutPK( + DBUContext *context, + const char *name, + size_t obj_size) +{ + DBUClass *cls = dbuClassCreate(name); + cls->context = context; + cls->obj_size = obj_size; + cxMapPut(context->classes, name, cls); + return cls; +}
--- a/dbutils/dbutils/dbutils.h Sun Feb 16 09:30:18 2025 +0100 +++ b/dbutils/dbutils/dbutils.h Sun Feb 16 15:14:45 2025 +0100 @@ -265,6 +265,10 @@ size_t obj_size, const char *primary_key_column, off_t primary_key_offset); +DBUClass* dbuRegisterClassWithoutPK( + DBUContext *context, + const char *name, + size_t obj_size); void dbuClassSetPrimaryKeyInt32(DBUClass *cls, const char *column_name, off_t offset); void dbuClassSetPrimaryKeyUInt32(DBUClass *cls, const char *column_name, off_t offset);
--- a/dbutils/object.c Sun Feb 16 09:30:18 2025 +0100 +++ b/dbutils/object.c Sun Feb 16 15:14:45 2025 +0100 @@ -449,7 +449,9 @@ DBUField *type_field = field.field; if(type_field && current_obj) { if(isnull) { - field.field->initDefaultValue(field.field, a, current_obj); + if(field.field->initDefaultValue) { + field.field->initDefaultValue(field.field, a, current_obj); + } } else { cxstring text = result->getText(result, i); //printf("getText(%d) = %s\n", i, text.ptr);