#118 wrong sql syntax for createTable and uniqueID

closed-wont-fix
nobody
MySQL (29)
5
2005-10-23
2005-10-13
Anonymous
No

class Setting(SQLObject):
key = StringCol(alternateID=True, length=10)
value=StringCol()

sqlobject svn from today.

the command
Setting.createTable()
gives the following output
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/site-packages/SQLObject-0.8dev_r1113-
py2.4.egg/sqlobj
ect/main.py", line 1308, in createTable
constraints = conn.createTable(cls)
File "/usr/lib/python2.4/site-packages/SQLObject-0.8dev_r1113-
py2.4.egg/sqlobj
ect/dbconnection.py", line 517, in createTable
self.query(createSql)
File "/usr/lib/python2.4/site-packages/SQLObject-0.8dev_r1113-
py2.4.egg/sqlobj
ect/dbconnection.py", line 303, in query
return self._runWithConnection(self._query, s)
File "/usr/lib/python2.4/site-packages/SQLObject-0.8dev_r1113-
py2.4.egg/sqlobj
ect/dbconnection.py", line 217, in _runWithConnection
val = meth(conn, *args)
File "/usr/lib/python2.4/site-packages/SQLObject-0.8dev_r1113-
py2.4.egg/sqlobj
ect/dbconnection.py", line 300, in _query
self._executeRetry(conn, conn.cursor(), s)
File "/usr/lib/python2.4/site-packages/SQLObject-0.8dev_r1113-
py2.4.egg/sqlobj
ect/mysql/mysqlconnection.py", line 60, in _executeRetry
return cursor.execute(query)
File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line
137, in execu
te
self.errorhandler(self, exc, value)
File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py",
line 33, in de
faulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.ProgrammingError: (1064, "You have an error
in your SQL syntax
; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'VARCHAR(30) NOT NULL
UNIQUE,\n value TEXT\n)' at line 3")

-
Sebastian
mightyofthefmc at gmx dot net

Discussion

  • Nobody/Anonymous

    Logged In: NO

    some additional information:
    also happens with sqlobject 0.7r1
    I use mysql version 4.1.14
    sqlobject tries to use following statement:

    CREATE TABLE setting (
    id INT PRIMARY KEY AUTO_INCREMENT,
    key VARCHAR(50) NOT NULL UNIQUE,
    value TEXT
    )

    This statement doesn't work on the mysql console.
    However: if i put the key inside backticks it works.
    Like this:
    CREATE TABLE setting (
    id INT PRIMARY KEY AUTO_INCREMENT,
    `key` VARCHAR(50) NOT NULL UNIQUE,
    value TEXT
    )

     
  • Oleg Broytman

    Oleg Broytman - 2005-10-23
    • status: open --> closed-wont-fix
     
  • Oleg Broytman

    Oleg Broytman - 2005-10-23

    Logged In: YES
    user_id=4799

    "key" is a reserved word in SQL92 and SQL99. SQLObject does
    not quote reserved words.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks