/* Build like so:
 * gcc test_libgda_field_with_hyphen.c `pkg-config libgda-5.0 --cflags --libs`
 */

#include <libgda/libgda.h>

GdaConnection* conn = NULL;


int main()
{
	gda_init();

	GError* error = NULL;
	conn = gda_connection_open_from_string("PostgreSQL",
		"HOST=localhost;PORT=5434;DB_NAME=glom_musiccollection211",
		"USERNAME=glom_default_developer_user;PASSWORD=glom_default_developer_password",
		GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE,
		&error);
	
	if (error) {
		g_warning("gda_connection_open_from_string() failed: %s\n", error->message);
		g_clear_error(&error);
		return 0;
	}

/* Generate SQL like this:	
  SELECT "artists"."artist_id", "artists"."descrip-tion" FROM "artists"
*/

  GdaSqlBuilder* builder = gda_sql_builder_new(GDA_SQL_STATEMENT_SELECT);
  gda_sql_builder_select_add_target(builder, "artists", NULL);
  gda_sql_builder_select_add_field(builder, "artist_id", "artists", NULL);
  gda_sql_builder_select_add_field(builder, "descrip-tion", "artists", NULL);

  GdaStatement* stmt = gda_sql_builder_get_statement(builder, &error);
  if (error) {
		g_warning("gda_sql_builder_get_statement() failed: %s\n", error->message);
		g_clear_error(&error);
		return 0;
	}

  GdaDataModel* model = gda_connection_statement_execute_select(
    conn, stmt, NULL, &error);
  if (error) {
		g_warning("gda_connection_statement_execute_select() failed: %s\n", error->message);
		g_clear_error(&error);
		return 0;
	}
 
  

	return 0;
}
