GdaExQueryEditorTable *table1;
GdaExQueryEditorTable *table2;
+ GdaExQueryEditorJoinType join_type;
+
GSList *fields1;
GSList *fields2;
} GdaExQueryEditorRelation;
gdaex_query_editor_add_relation (GdaExQueryEditor *qe,
const gchar *table1,
const gchar *table2,
+ GdaExQueryEditorJoinType join_type,
...)
{
GdaExQueryEditorPrivate *priv;
}
relation->table2 = table;
- va_start (fields, table2);
+ va_start (fields, join_type);
while ((field_name1 = va_arg (fields, gchar *)) != NULL
&& (field_name2 = va_arg (fields, gchar *)) != NULL)
if (create_relation)
{
+ relation->join_type = join_type;
priv->relations = g_slist_append (priv->relations, relation);
}
else
sqlbuilder = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
+ /* SHOW */
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->lstore_show), &iter))
{
guint id_target1;
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->lstore_show), &iter));
}
+ /* WHERE */
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->tstore_where), &iter))
{
guint link_type;
field = g_hash_table_lookup (table->fields, field_name);
id_field = gda_sql_builder_add_id (sqlbuilder,
- g_strconcat (case_insensitive ? "lower(" : "",
+ g_strconcat (case_insensitive ? "LOWER(" : "",
table->name, ".", field->name,
case_insensitive ? ")" : "",
NULL));
}
}
+ /* ORDER */
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->lstore_order), &iter))
{
do
gdaex_query_editor_table_add_field (qe, "orders", *field);
g_free (field);
+ gdaex_query_editor_add_relation (qe,
+ "clients", "orders",
+ GDAEX_QE_JOIN_TYPE_LEFT,
+ "id", "id_clients",
+ NULL);
+
+ field = g_new0 (GdaExQueryEditorField, 1);
+ field->name = g_strdup ("amount");
+ field->name_visible = g_strdup ("Amount");
+ field->type = GDAEX_QE_FIELD_TYPE_DOUBLE;
+ field->for_show = TRUE;
+ field->for_where = TRUE;
+ field->available_where_type = GDAEX_QE_WHERE_TYPE_NUMBER;
+ gdaex_query_editor_table_add_field (qe, "orders", *field);
+ g_free (field);
+
w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (w), 610, 400);
gtk_window_set_modal (GTK_WINDOW (w), TRUE);