Re: [gnome-db] New API to build statement from a strutural description.



I think the API for GdaSqlBuilder could be like:

_new (GdaSqlStatementType type)
* This must build the most basic statement with no fields, table or parameters.

_set_table (GdaSqlBuilder *builder, const gchar* table, gboolean fill, GError *error)
* This could set the table to use in the statament and if 'fill' is set to TRUE then adds the all the table's fields and a condition for the Primary Key(s) to a where clausure.

_new_for_table (GdaSqlStatementType type, const gchar *table)
* This must build the most basic statement for the type specified using the given table and with a where clasure for the PrimaryKey(s) and one parameter to set (may be called "+1"). For INSERT one parameter for each filed in the table.

_add_condition_from_string (GdaSqlBuilder *builder, gint where_id, const gchar* condition, GError *error)
* This adds a new condition at the given 'where_id' parsing the 'condition', if the given fields not exists in the statement's tables then set 'error'.

_add_condition (GdaSqlBuilder *builder, gint where_id, const gchar* field, GdaSqlOperatorType operator_type, const gchar *paramenter_name, GError *error)
* This adds a new condition at the given 'where_id', use 'field', 'operator_type' and 'parameter_name' to create a condition in the form, for a GDA_SQL_OPERATOR_TYPE_EQ, 'field = ##parameter_name'. If the given field not exists in the statement's tables then set 'error'.

_add_field (GdaSqlBuilder *builder, gint part_id, const gchar* field, GError *error)
* Adds a field at the given 'part_id' (for example the main SELECT or a sub-SELECT), if the given fields not exists in the statement's tables then set 'error'.

Some general ideas:

You can add a field and get its ID, then when adding a condition with that id (may be just given the field's name), it could create a 'default' condition like FIELD = ##PARAMETER, getting the condition ID you can change the OperatorType and parameter's name.

More to come... just let me check in detail the actual code.

2009/3/19 Vivien Malerba <vmalerba gmail com>
Hi!

I've just committed to svn trunk the code for the GdaSqlBuilder object which builds statements from their structural description, instead of creating a statement from some SQL by parsing it.

For example to build a DELETE statement the user does:
* tell the table to use
* tell the condition of the delete statement.
* get a GdaStatement object which can be used as any other statement.

The code is very new and still missing many features, but there is already some doc and some example in the samples/SqlBuilder directory to show its usage.

Before I implement more, I'd like to have a feedback about that API.

Regards,

Vivien

_______________________________________________
gnome-db-list mailing list
gnome-db-list gnome org
http://mail.gnome.org/mailman/listinfo/gnome-db-list




--
Trabajar, la mejor arma para tu superación
"de grano en grano, se hace la arena" (R) (en trámite, pero para los cuates: LIBRE)


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