# HG changeset patch # User Olaf Wintermann # Date 1739715285 -3600 # Node ID cf0b13708fd96924ee4c27aa799277391b5078e9 # Parent 421555fa9ce48d1724f4a42266d6a21739ca4944 add function for registering classes without PK diff -r 421555fa9ce4 -r cf0b13708fd9 dbutils/dbutils.c --- 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; +} diff -r 421555fa9ce4 -r cf0b13708fd9 dbutils/dbutils/dbutils.h --- 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); diff -r 421555fa9ce4 -r cf0b13708fd9 dbutils/object.c --- 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);