[libgda] gda_compute_dml_statements(): handle column's default value and autoincrement



commit 58c59c5cb1835044dd27744af8505fb17276b820
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sun Jul 24 13:10:29 2011 +0200

    gda_compute_dml_statements(): handle column's default value and autoincrement

 libgda/gda-util.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index ab3fb06..98ba84f 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -1178,6 +1178,12 @@ gda_compute_dml_statements (GdaConnection *cnc, GdaStatement *select_stmt, gbool
 			pspec->g_type = (tcol->gtype != GDA_TYPE_NULL) ? tcol->gtype: G_TYPE_STRING;
 			pspec->nullok = tcol->nullok;
 			expr = gda_sql_expr_new (GDA_SQL_ANY_PART (ist));
+			if (tcol->default_value)
+				g_value_set_string ((expr->value = gda_value_new (G_TYPE_STRING)),
+						    tcol->default_value);
+			else if (gda_meta_table_column_get_attribute (tcol, GDA_ATTRIBUTE_AUTO_INCREMENT))
+				g_value_set_string ((expr->value = gda_value_new (G_TYPE_STRING)), "''");
+
 			expr->param_spec = pspec;
 			insert_values_list = g_slist_append (insert_values_list, expr);
 		}
@@ -1187,6 +1193,11 @@ gda_compute_dml_statements (GdaConnection *cnc, GdaStatement *select_stmt, gbool
 			pspec->g_type = (tcol->gtype != GDA_TYPE_NULL) ? tcol->gtype: G_TYPE_STRING;
 			pspec->nullok = tcol->nullok;
 			expr = gda_sql_expr_new (GDA_SQL_ANY_PART (ust));
+			if (tcol->default_value)
+				g_value_set_string ((expr->value = gda_value_new (G_TYPE_STRING)),
+						    tcol->default_value);
+			else if (gda_meta_table_column_get_attribute (tcol, GDA_ATTRIBUTE_AUTO_INCREMENT))
+				g_value_set_string ((expr->value = gda_value_new (G_TYPE_STRING)), "''");
 			expr->param_spec = pspec;
 			ust->expr_list = g_slist_append (ust->expr_list, expr);
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]