Re: [gnome-db] query well formed

On 6/21/07, Andrea Zagli <azagli inwind it> wrote:
what do you mean with "query well formed"?

because, for example, if i create a GdaQuery with gda_query_new_from_sql from "SELECT * FROM clients ORDER BY nameGROUP BY year" (there's no space between name and group), gda_query_is_well_formed returns TRUE (without errors), while gda_query_new_from_sql has returned an error (as it must do)

each GdaQuery object has an internal structure (composed of
GdaQueryField, GdaQueryTarget, ...) which must respect some rules as
mentionned in the doc (section about DML queries).

However there are some SQL queries which can't be represented by this
kind of internal structure, such as DDL queries, and all the
proprietary extensions of each DBMS. When one tries to make a GdaQuery
with such SQL, then the GdaQuery simply stores the SQL string to be
rendered (and also parses any parameters it ma contain). This is why
gda_query_is_well_formed returns TRUE on such SQL, but
gda_query_new_from_sql has returned an error as it was not able to
parse it correctly.

You should test the GdaQuery's internal type using gda_query_get_query_type().

moreover, gda_renderer_render_as_sql returns the same string used with gda_query_new_from_sql whitout errors: i thought that it returned NULL and an error

No, it's up to the programmer to test if gda_query_get_query_type()
returns GDA_QUERY_TYPE_NON_PARSED_SQL in which case there might be a

Hope this helps,


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