From 806586428ae2fb699d75b6a258355af98d253d5c Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Wed, 2 Dec 2015 16:24:48 +0100 Subject: [PATCH] Added function GdaExSqlBuilder::field. --- src/sqlbuilder.c | 18 ++++++++++++++++++ src/sqlbuilder.h | 1 + tests/sqlbuilder.c | 2 ++ 3 files changed, 21 insertions(+) diff --git a/src/sqlbuilder.c b/src/sqlbuilder.c index fd21622..afbe3a1 100644 --- a/src/sqlbuilder.c +++ b/src/sqlbuilder.c @@ -345,6 +345,24 @@ gdaex_sql_builder_join (GdaExSqlBuilder *sqlb, va_end (ap); } +/** + * gdaex_sql_builder_field: + * @sqlb: + * @table_name: + * @field_name: + * @field_alias: + * @gval: + * + */ +void +gdaex_sql_builder_field (GdaExSqlBuilder *sqlb, const gchar *table_name, const gchar *field_name, const gchar *field_alias, GValue *gval) +{ + GdaExSqlBuilderTable *t; + + t = gdaex_sql_builder_get_table (sqlb, table_name, NULL, TRUE); + gdaex_sql_builder_get_field (sqlb, t, field_name, field_alias, gval, TRUE); +} + /** * gdaex_sql_builder_fields: * @sqlb: diff --git a/src/sqlbuilder.h b/src/sqlbuilder.h index 406b306..e3f2b9c 100644 --- a/src/sqlbuilder.h +++ b/src/sqlbuilder.h @@ -65,6 +65,7 @@ void gdaex_sql_builder_join (GdaExSqlBuilder *sqlb, GdaSqlSelectJoinType join_type, ...); +void gdaex_sql_builder_field (GdaExSqlBuilder *sqlb, const gchar *table_name, const gchar *field_name, const gchar *field_alias, GValue *gval); void gdaex_sql_builder_fields (GdaExSqlBuilder *sqlb, ...); GdaSqlBuilderId gdaex_sql_builder_where (GdaExSqlBuilder *sqln, GdaSqlOperatorType op, diff --git a/tests/sqlbuilder.c b/tests/sqlbuilder.c index be00c45..e12c229 100644 --- a/tests/sqlbuilder.c +++ b/tests/sqlbuilder.c @@ -38,6 +38,8 @@ main (int argc, char **argv) "pippo", "name", "the_name", NULL, NULL); + gdaex_sql_builder_field (sqlb, "pippo", "income", NULL, NULL); + gdaex_sql_builder_join (sqlb, GDA_SQL_SELECT_JOIN_INNER, "pippo", "id", "", GDA_SQL_OPERATOR_TYPE_EQ, -- 2.49.0