In gluon/sql.py there is a

        if self._db._dbname == 'mysql':
            fields.append('PRIMARY KEY(%s)' % field[0].name)
            other = ' ENGINE=InnoDB CHARACTER SET utf8;'

should be

        if self._db._dbname == 'mysql':
            fields.append('PRIMARY KEY(%s)' % self.fields[0])
            other = ' ENGINE=InnoDB CHARACTER SET utf8;'

It is a bug. I am fixing it and reposting.

On Nov 10, 6:58 am, des <dmukuzwa...@gmail.com> wrote:
> Hi guys i was trying to start the welcome and examples apps and i get
> this error with both of them:
>
> (i'm using mysql)
>
> SQL generated :
>
> CREATE TABLE mytable(
>     id INT AUTO_INCREMENT NOT NULL,
>     myfield VARCHAR(512),
>     PRIMARY KEY(SUBSTRING(mytable.myfield,1,1))
> ) ENGINE=InnoDB CHARACTER SET utf8;
>
> Traceback:
>
> Traceback (most recent call last):
>   File "/home/desmond/python-stuff/web2py/web2py/gluon/restricted.py",
> line 184, in restricted
>   File "/home/desmond/webapps/web2py/applications/welcome/models/
> db.py", line 51, in <module>
>     db.define_table('mytable',Field('myfield','string'))
>   File "/home/desmond/python-stuff/web2py/web2py/gluon/sql.py", line
> 1205, in define_table
>   File "/home/desmond/python-stuff/web2py/web2py/gluon/sql.py", line
> 1607, in _create
>   File "/home/desmond/python-stuff/web2py/web2py/gluon/sql.py", line
> 879, in <lambda>
>   File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line
> 166, in execute
>     self.errorhandler(self, exc, value)
>   File "/var/lib/python-support/python2.5/MySQLdb/connections.py",
> line 35, in defaulterrorhandler
>     raise errorclass, errorvalue
> 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 'SUBSTRING(mytable.myfield,1,1))\n) ENGINE=InnoDB
> CHARACTER SET utf8' at line 4")
>
> I am a newbie but would really like to use web2py any help will be
> appreciated
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to