static Audit *audit_new_ (void);
static gboolean load_fields (Audit *audit,
+ Datasource *datasource,
Table *table);
static gboolean load_tables (Audit *audit,
Datasource *datasource);
static gboolean
load_fields (Audit *audit,
+ Datasource *datasource,
Table *table)
{
GdaDataModel *dm;
+ GdaDataModel *dm_table;
+
gchar *sql;
gint rows, row;
+
Field *cam;
AuditPrivate *priv = AUDIT_GET_PRIVATE (audit);
+ /* check if table exists */
+ dm_table = gdaex_query (datasource->gdaex,
+ g_strdup_printf ("SELECT * FROM %s", table->name));
+ if (dm_table == NULL)
+ {
+ g_warning ("The table «%s» doesn't exist on db.", table->name);
+ return FALSE;
+ }
+
sql = g_strdup_printf ("SELECT id, name FROM fields"
" WHERE status <> 'D' AND id_tables = %d",
table->id);
cam->id = gdaex_data_model_get_field_value_integer_at (dm, row, "id");
cam->name = gdaex_data_model_get_field_value_stringify_at (dm, row, "name");
+ if (gda_data_model_get_column_index (dm_table, cam->name) < 0)
+ {
+ g_warning ("The field «%s» doesn't exists on table «%s».",
+ cam->name, table->name);
+ return FALSE;
+ }
+
table->fields = g_list_append (table->fields, (gpointer)cam);
}
static gboolean
load_tables (Audit *audit,
- Datasource *datasource)
+ Datasource *datasource)
{
GdaDataModel *dm;
gchar *sql;
tab->id = gdaex_data_model_get_field_value_integer_at (dm, row, "id");
tab->name = gdaex_data_model_get_field_value_stringify_at (dm, row, "name");
- datasource->tables = g_list_append (datasource->tables, (gpointer)tab);
-
/* for each table must be loaded fields */
tab->fields = NULL;
- if (!load_fields (audit, tab))
+ if (!load_fields (audit, datasource, tab))
{
return FALSE;
}
+
+ datasource->tables = g_list_append (datasource->tables, (gpointer)tab);
}
return TRUE;