wmjie / ibm-db

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

Invalid sql statements generated with '(single quotes) in field names. #84

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a table object
2. Specify the schema and table name using
    using_table_options(schema='myschema')
    using_options(tablename='mytable')
3. Query table object with all

What is the expected output? What do you see instead?
A select statement should be generated with the form myschema.mytable.field. 
Instead a select statement is created with the form myschema.mytable.'field' . 
This causes the statement to fail with the following error:

  File "c:\python25\lib\site-packages\sqlalchemy-0.7.2-py2.5.egg\sqlalchemy\orm\query.py", line 1729, in all
    return list(self)
  File "c:\python25\lib\site-packages\sqlalchemy-0.7.2-py2.5.egg\sqlalchemy\orm\query.py", line 1839, in __iter__
    return self._execute_and_instances(context)
  File "c:\python25\lib\site-packages\sqlalchemy-0.7.2-py2.5.egg\sqlalchemy\orm\query.py", line 1854, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "c:\python25\lib\site-packages\sqlalchemy-0.7.2-py2.5.egg\sqlalchemy\engine\base.py", line 1399, in execute
    params)
  File "c:\python25\lib\site-packages\sqlalchemy-0.7.2-py2.5.egg\sqlalchemy\engine\base.py", line 1532, in _execute_clauseelement
    compiled_sql, distilled_params
  File "c:\python25\lib\site-packages\sqlalchemy-0.7.2-py2.5.egg\sqlalchemy\engine\base.py", line 1640, in _execute_context
    context)
  File "c:\python25\lib\site-packages\sqlalchemy-0.7.2-py2.5.egg\sqlalchemy\engine\base.py", line 1633, in _execute_context
    context)
  File "c:\python25\lib\site-packages\sqlalchemy-0.7.2-py2.5.egg\sqlalchemy\engine\default.py", line 325, in do_execute
    cursor.execute(statement, parameters)
  File "c:\Python25\lib\site-packages\ibm_db-1.0.5-py2.5-win32.egg\ibm_db_dbi.py", line 1280, in execute
    self._prepare_helper(operation)
  File "c:\Python25\lib\site-packages\ibm_db-1.0.5-py2.5-win32.egg\ibm_db_dbi.py", line 1165, in _prepare_helper
    raise _get_exception(inst)
sqlalchemy.exc.ProgrammingError: (ProgrammingError) 
ibm_db_dbi::ProgrammingError: [IBM][CLI Driver][DB2/LINUXX8664] SQL0104N  An 
unexpected token "." was found following "SELECT mytable.field".

What version of the product are you using? On what operating system?
ibm_db_sa branch running on windows 7 64 bit. Python 2.5

Original issue reported on code.google.com by TjaartB...@gmail.com on 4 Oct 2011 at 12:11

GoogleCodeExporter commented 9 years ago
Thank you, this has been fixed revision #146.

http://code.google.com/p/ibm-db/source/detail?r=146

Original comment by jazlee on 5 Oct 2011 at 7:23