Bug 364810

Summary: Error while inserting rows into table with schema containing reserved words
Product: [Applications] KEXI Reporter: Jarosław Staniek <staniek>
Component: KexiDBAssignee: Jarosław Staniek <staniek>
Status: CLOSED FIXED    
Severity: normal CC: adam, inksi
Priority: NOR    
Version: 2.9.11   
Target Milestone: 3.0   
Platform: Other   
OS: Linux   
URL: https://forum.kde.org/viewtopic.php?f=221&t=133426
Latest Commit: Version Fixed In: 3.0.0
Sentry Crash Report:
Attachments: Test file that fails

Description Jarosław Staniek 2016-06-27 12:03:13 UTC
Error while inserting rows into table with schema containing reserved words, e.g. table name == "table" or field name "from". 

Solution: escape identifiers in any place where necessary. 


Reproducible: Always

Steps to Reproduce:
1. Create table such as "CREATE TABLE "TABLE" ("FROM" INTEGER)
2. Go to the data view and try to insert one record


Actual Results:  
"Record inserting failed"



In fact records get inserted but retrieving autoincremented values fails.
Comment 1 Jarosław Staniek 2016-06-27 12:15:12 UTC
Created attachment 99722 [details]
Test file that fails

Try to insert records into "table" and "index" tables.
Comment 2 Jarosław Staniek 2016-06-27 12:35:10 UTC
Git commit 69b8f18d4b1102fed1d06de07f6d1c953e00e617 by Jaroslaw Staniek.
Committed on 27/06/2016 at 12:20.
Pushed by staniek into branch 'calligra/2.9'.

CalligraDB: Connection::lastInsertedAutoIncValue: escape <table> and <name> in "SELECT <table>.<name> FROM <table>"

M  +2    -1    libs/db/connection.cpp

http://commits.kde.org/calligra/69b8f18d4b1102fed1d06de07f6d1c953e00e617
Comment 3 Jarosław Staniek 2016-07-03 00:22:15 UTC
Git commit 729e2937e426bb9b715f0152aed66b5b11d2676a by Jaroslaw Staniek.
Committed on 03/07/2016 at 00:12.
Pushed by staniek into branch 'escape-sequences-staniek'.

KDbConnection::lastInsertedAutoIncValue: escape <table> and <name> in "SELECT <table>.<name> FROM <table>"

>From calligra.git 69b8f18d4b1102fe

M  +3    -2    src/KDbConnection.cpp

http://commits.kde.org/kdb/729e2937e426bb9b715f0152aed66b5b11d2676a
Comment 4 Jarosław Staniek 2016-07-18 08:28:00 UTC
Git commit c7111e0cf2335ac24bccd249284cfd1116bf2a1b by Jaroslaw Staniek.
Committed on 18/07/2016 at 07:57.
Pushed by staniek into branch 'master'.

KDbConnection::lastInsertedAutoIncValue: escape <table> and <name> in "SELECT <table>.<name> FROM <table>"

>From calligra.git 69b8f18d4b1102fe

M  +3    -2    src/KDbConnection.cpp

http://commits.kde.org/kdb/c7111e0cf2335ac24bccd249284cfd1116bf2a1b