- Solucionado bug en el metodo db_model_create_where
This commit is contained in:
Juan Ferrer Toribio 2014-06-25 13:25:21 +02:00
parent a02e657579
commit 56dd9dfc5f
1 changed files with 25 additions and 19 deletions

View File

@ -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)