iheanyi / ibm-db

Automatically exported from code.google.com/p/ibm-db
0 stars 0 forks source link

Columns Select Incorrectly escaped when Column name is same as reserved keyword (ibm_db_sa) #162

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Have table with column that is same name as reserved keyword, e.g. "Source"
2. Query select from SQLAlchemy
3. Execute query

What is the expected output? What do you see instead?
Expected SQL Select As:
"SCHEMA".table.column_name
Instead, this is generated:
"SCHEMA".table."column"

What version of the product are you using? On what operating system?
SQLAlchemy: v.0.9.7
ibm_db_sa: v0.3.1
OS: Windows 8

Please provide any additional information below.

Normal Column Sample:

"SCHEMA".table.column AS "SCHEMA_table_column"', 

Incorrect Column Sample:
"SCHEMA".table."column" AS "SCHEMA_table_column"

Resulting DB Error:
SQL0206N  "SCHEMA.TABLE.column" is not valid in the context where it is used.

On a side note: I have attempted to remove "Source" as a reserved keyword in 
base.py RESERVED_WORDS set variable. This fixes the problem, however, I am 
unsure whether or not it will affect other areas of the code.

Original issue reported on code.google.com by XcepticZoki@gmail.com on 7 Sep 2014 at 1:17

GoogleCodeExporter commented 9 years ago
>>>
"SCHEMA".table."column" AS "SCHEMA_table_column"
<<<
Above sql snippet is not wrong for reserve words. 
You are getting error this error since your table is not created by SQLAlchemy, 
and while creating table you have not quoted reserve words column name 
properly, you can eliminate this error by using uppercase column name.    

Original comment by rahul.pr...@in.ibm.com on 8 Sep 2014 at 6:22