https://bugs.kde.org/show_bug.cgi?id=420599

--- Comment #4 from jordi fita i mas <jf...@infoblitz.com> ---
Sorry if i misunderstood it, but from your comment that says

> This time I am unsure it applies here. See #376052 and particular solution at 
> https://bugs.kde.org/show_bug.cgi?id=376052#c2.

it seems like you are talking about the conversion from KDbSQL dialect to the
driver’s dialect.
That works as expected because, as you noted, the query

SELECT group FROM source

does indeed produce the expected result.
However, what i am reporting is a problem with the SQL that Kexi stores in its
kexi__objectdata table for queries.

In fact, i did not write the SQL query in the attached file; i only used the
designer mode and switched to text view just to debug, as it were, the results.

My understanding is that KexiQueryDesignerGuiEditor uses a KDbQueryScheme to
build the SELECT query without resorting to string manipulations, but when it
is time to save the query and serialize it into kexi__objectdata uses a
KDbNativeStatementBuilder to create the SQL string. KDbNativeStatementBuilder
calls KDb::escapeIdentifier to escape, if needed, field and table names and, in
this case, recognizes the group column as a SQL keyword and escapes it as
"group" — KDb::escapeIdentifier always uses double quote. Then, to load the
query in data mode, Kexi reads the serialized SQL from kexi__objectdata with
KDbParser that recognizes "group" as the string literal 'group' instead of a
column name.  Afterwards, this query is converted to the driver-specific
dialect, but at that moment it is too late and the column is now an anonymous
literal.

One source of confusion is that i dot know if the “native” in
KDbNativeStatementBuilder refers to driver-native or KDbSql-native statement.
If the former, the problem is from Kexi and not KDb, but then
KDbNativeStatementBuilder should use KDbConnection::escapeIdentifier instead of
KDb::escapeIdentifier. If the latter, KDbNativeStatementBuilder should build
its statements in a way that KDbParser should be able read correctly.


> This should work 
>
> SELECT [group] FROM source
>
> once this wish is implemented: https://bugs.kde.org/show_bug.cgi?id=332161

Using [] to escape identifiers would free the double quotes to be used only for
string literals, but it seems to me that KDbNativeStatementBuilder, or
KDB::escapeIdentifier, should still be corrected to use the proper KDbSql
escape characters.


Again, sorry if i misunderstood your response.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to