SQLite Provider: Reading a Date Fails
The database is:
$ sqlite3 planner
sqlite> CREATE TABLE project (
(x1...> id INTEGER PRIMARY KEY AUTOINCREMENT,
(x1...> name TEXT NOT NULL,
(x1...> start DATE NOT NULL DEFAULT CURRENT_TIMESTAMP
(x1...> );
sqlite> INSERT INTO project (name) VALUES ("Manhattan");
sqlite> SELECT * FROM project;
1|Manhattan|2024-03-22 22:36:18
I tried to access with libgda:
sql = "SELECT id, name, start FROM project";
stmt = gda_sql_parser_parse_string(parser, sql, NULL, &error);
model = gda_connection_statement_execute_select(cnc, stmt, NULL, &error);
n_rows = gda_data_model_get_n_rows(model);
for (int row = 0; row < n_rows; row++) {
value = gda_data_model_get_value_at(model, 2, row, &error);
if (!value)
goto done;
}
done:
if (error) {
g_print("ERROR: %s\n", error->message);
g_clear_error(&error);
}
I got:
ERROR: Invalid date '2024-03-22 22:36:18' (date format should be YYYY-MM-DD)
gda_parse_iso8601_date()
is too strict.
The date is read. But since there are characters left, it is considered as an error.
Edited by Ahmed Baïzid