mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-03-10 00:20:54 +08:00
Fix crash when a date column lacks a Format property brianb/mdbtools#132
This commit is contained in:
@@ -270,6 +270,11 @@ quote_with_squotes(const gchar* value)
|
|||||||
return quote_generic(value, '\'', '\'');
|
return quote_generic(value, '\'', '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mdb_col_is_shortdate(const MdbColumn *col) {
|
||||||
|
const char *format = mdb_col_get_prop(col, "Format");
|
||||||
|
return format && !strcmp(format, "Short Date");
|
||||||
|
}
|
||||||
|
|
||||||
MDB_DEPRECATED(char*,
|
MDB_DEPRECATED(char*,
|
||||||
mdb_get_coltype_string(MdbBackend *backend, int col_type))
|
mdb_get_coltype_string(MdbBackend *backend, int col_type))
|
||||||
{
|
{
|
||||||
@@ -299,7 +304,6 @@ mdb_coltype_takes_length(MdbBackend *backend, int col_type))
|
|||||||
return backend->types_table[col_type].needs_length;
|
return backend->types_table[col_type].needs_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const MdbBackendType*
|
const MdbBackendType*
|
||||||
mdb_get_colbacktype(const MdbColumn *col) {
|
mdb_get_colbacktype(const MdbColumn *col) {
|
||||||
MdbBackend *backend = col->table->entry->mdb->default_backend;
|
MdbBackend *backend = col->table->entry->mdb->default_backend;
|
||||||
@@ -309,8 +313,7 @@ mdb_get_colbacktype(const MdbColumn *col) {
|
|||||||
if (col_type == MDB_LONGINT && col->is_long_auto && backend->type_autonum)
|
if (col_type == MDB_LONGINT && col->is_long_auto && backend->type_autonum)
|
||||||
return backend->type_autonum;
|
return backend->type_autonum;
|
||||||
if (col_type == MDB_DATETIME && backend->type_shortdate) {
|
if (col_type == MDB_DATETIME && backend->type_shortdate) {
|
||||||
const char *format = mdb_col_get_prop(col, "Format");
|
if (mdb_col_is_shortdate(col))
|
||||||
if (format && !strcmp(format, "Short Date"))
|
|
||||||
return backend->type_shortdate;
|
return backend->type_shortdate;
|
||||||
}
|
}
|
||||||
return &backend->types_table[col_type];
|
return &backend->types_table[col_type];
|
||||||
@@ -842,7 +845,7 @@ generate_table_schema(FILE *outfile, MdbCatalogEntry *entry, char *dbnamespace,
|
|||||||
else if (!strcmp(defval, "No"))
|
else if (!strcmp(defval, "No"))
|
||||||
fputs("FALSE", outfile);
|
fputs("FALSE", outfile);
|
||||||
else if (!g_ascii_strcasecmp(defval, "date()")) {
|
else if (!g_ascii_strcasecmp(defval, "date()")) {
|
||||||
if (!strcmp(mdb_col_get_prop(col, "Format"), "Short Date"))
|
if (mdb_col_is_shortdate(col))
|
||||||
fputs(mdb->default_backend->short_now, outfile);
|
fputs(mdb->default_backend->short_now, outfile);
|
||||||
else
|
else
|
||||||
fputs(mdb->default_backend->long_now, outfile);
|
fputs(mdb->default_backend->long_now, outfile);
|
||||||
|
|||||||
Reference in New Issue
Block a user