mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-02-26 13:52:42 +08:00
mdb-export: Add boolean words option (TRUE/FALSE)
Adds "-B" (--boolean-words) option to mdb-export, which will reconfigure mdb/data.c to export TRUE/FALSE for boolean values instead of 1/0. The option is needed to support BOOLEAN fields on PostgreSQL, which will not implicitly cast bare 1/0 into a BOOLEAN value. Value literals are the SQL TRUE/FALSE, and _quoted_ words meaning true/false and _quoted_ '1'/'0'. With this flag the SQL TRUE/FALSE values are output, which should work with several SQL databases. PostgreSQL Reference: http://www.postgresql.org/docs/current/static/datatype-boolean.html
This commit is contained in:
@@ -89,6 +89,7 @@ main(int argc, char **argv)
|
||||
char *escape_char = NULL;
|
||||
int header_row = 1;
|
||||
int quote_text = 1;
|
||||
int boolean_words = 0;
|
||||
char *insert_dialect = NULL;
|
||||
char *date_fmt = NULL;
|
||||
char *namespace = NULL;
|
||||
@@ -108,6 +109,7 @@ main(int argc, char **argv)
|
||||
{ "escape", 'X', 0, G_OPTION_ARG_STRING, &escape_char, "Use <char> to escape quoted characters within a field. Default is doubling.", "format"},
|
||||
{ "namespace", 'N', 0, G_OPTION_ARG_STRING, &namespace, "Prefix identifiers with namespace", "namespace"},
|
||||
{ "bin", 'b', 0, G_OPTION_ARG_STRING, &str_bin_mode, "Binary export mode", "strip|raw|octal"},
|
||||
{ "boolean-words", 'B', 0, G_OPTION_ARG_NONE, &boolean_words, "Use TRUE/FALSE in Boolean fields (default is 0/1)", NULL},
|
||||
{ NULL },
|
||||
};
|
||||
GError *error = NULL;
|
||||
@@ -154,6 +156,9 @@ main(int argc, char **argv)
|
||||
if (date_fmt)
|
||||
mdb_set_date_fmt(date_fmt);
|
||||
|
||||
if (boolean_words)
|
||||
mdb_set_boolean_fmt_words();
|
||||
|
||||
if (str_bin_mode) {
|
||||
if (!strcmp(str_bin_mode, "strip"))
|
||||
bin_mode = MDB_BINEXPORT_STRIP;
|
||||
|
||||
Reference in New Issue
Block a user