From 56dd9dfc5f567f6fd61e2f4a12074c8542447acd Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 25 Jun 2014 13:25:21 +0200 Subject: [PATCH] DbModel: - Solucionado bug en el metodo db_model_create_where --- db/db-model.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/db/db-model.c b/db/db-model.c index cefc186..50e07dd 100644 --- a/db/db-model.c +++ b/db/db-model.c @@ -96,14 +96,6 @@ struct _DbModelPrivate // Structures -typedef struct -{ - gint col; - gint order; - DbRow * null_row; -} -SortInfo; - typedef struct { DbModel * self; @@ -130,6 +122,14 @@ typedef struct } DbJoin; +typedef struct +{ + gint col; + gint order; + DbRow * null_row; +} +SortInfo; + enum { DB_MODEL_UNSORTED_SORT_COLUMN_ID = -2, @@ -2303,6 +2303,9 @@ static SqlObject * db_model_create_where (DbModel * self, SqlObject * where; SqlList * and_operands; + if (!tinfo->pkeys) + return NULL; + where = sql_operation_new (SQL_OPERATION_TYPE_AND); and_operands = sql_list_new (SQL_TYPE_EXPR); @@ -2319,24 +2322,27 @@ static SqlObject * db_model_create_where (DbModel * self, g_value = &row->value[col]; - for (n = operation->updated; n && (u = n->data); n = n->next) - if (u->column == col) - { - g_value = u->value; - break; + if (!for_insert) + { + for (n = operation->updated; n && (u = n->data); n = n->next) + if (u->column == col) + { + g_value = u->value; + break; + } + + if (!gvn_value_is_null (g_value)) + value = sql_value_new_with_value (g_value); } - - if (!gvn_value_is_null (g_value)) - { - value = sql_value_new_with_value (g_value); - } - else if (for_insert) + else { const GValue * def = gvn_param_spec_get_default (priv->column[col].spec); if (def && G_IS_VALUE (def) && G_VALUE_TYPE (def) == SQL_TYPE_FUNCTION) value = g_value_get_object (def); + else + value = sql_value_new_with_value (g_value); } if (!value)