Referencing user results in syntax-error?

35 views
Skip to first unread message

Alec Taylor

unread,
Jul 26, 2012, 4:37:22 PM7/26/12
to web...@googlegroups.com
I checked the documentation to make sure, and either one of the commented out lines works, but I keep getting this:

<class 'sqlite3.OperationalError'> near ".": syntax error

It one (well both) of the commented out lines that give this error, because commenting them out makes the error go away.

db.define_table(
    'rsvp_list',
    Field('rsvp', notnull=True, requires=IS_IN_SET('Yes', 'Maybe', 'No')),
    Field('event_id', 'reference db.event', notnull=True, requires=IS_IN_DB(db, db.event, '%(event_name)s [%(id)%]')),
    #Field("person", db.auth_user, default=auth.user if auth.user else None)
    #Field('person', db.auth_user, notnull=True, default=auth.user_id)
)

How can I get this working?

Thanks for all suggestions,

Alec Taylor

Massimo Di Pierro

unread,
Jul 26, 2012, 4:45:04 PM7/26/12
to web...@googlegroups.com
Person cannot be not null and default to auth.user_id which likely is null.

It also cannot defaul to auth.user.

Use the second line and remove notnull

Alec Taylor

unread,
Jul 27, 2012, 2:01:43 AM7/27/12
to web...@googlegroups.com
Thanks, but that gave me the same error.

Niphlod

unread,
Jul 27, 2012, 3:25:58 AM7/27/12
to web...@googlegroups.com
Massimo is right, but you're having the error for another reason.

it's plain and clear (Variables section). You are also lucky that in all of this statement there is only one dot.

('ALTER TABLE rsvp_list ADD event_id INTEGER REFERENCES db.event (id) ON DELETE CASCADE;',)

you have

Field('event_id', 'reference db.event'

that needs to be

Field('event_id', 'reference event'

Alec Taylor

unread,
Jul 27, 2012, 8:32:50 AM7/27/12
to web...@googlegroups.com
Thanks, that did the trick.

--
 
 
 

Reply all
Reply to author
Forward
0 new messages