list:integer X list:reference for auth_user table

134 views
Skip to first unread message

Bruno Rocha

unread,
Dec 6, 2010, 11:50:55 AM12/6/10
to web...@googlegroups.com

Is there any important difference?

1.
Field('assigned_to','list:integer',requires=IS_IN_DB(db,db.auth_user.id,'db.auth_user.first_name',multiple=True)),

2.
Field('assigned_to','list:reference auth_user'),


In the case of 2, how to represent as 'db.auth_user.first_name' for multiple users?

--

Bruno Rocha
http://about.me/rochacbruno/bio

Kuba Kucharski

unread,
Dec 6, 2010, 2:44:35 PM12/6/10
to web...@googlegroups.com
> Field('assigned_to','list:reference auth_user'),
>
> In the case of 2, how to represent as 'db.auth_user.first_name' for multiple
> users

requires=IS_IN_DB(db,'auth_user.id','%(first_name)s',multiple=True)

Bruno Rocha

unread,
Dec 6, 2010, 3:27:30 PM12/6/10
to web...@googlegroups.com
So I understand that there are no difference between the two forms, right?

as list:reference and list:integer will store the same in db.

mdipierro

unread,
Dec 6, 2010, 4:01:35 PM12/6/10
to web2py-users
yes. the difference is only in the default validator.

kulin shah

unread,
Jul 7, 2015, 5:40:39 PM7/7/15
to web...@googlegroups.com
Hi,
I am a newbie to web2py and programming in general. I have something like this:
Field('cc_list','list:integer',requires=IS_EMPTY_OR(IS_IN_DB(db,'auth_user.id',db.auth_user._format,multiple=True))),
but this is giving an error:

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
Traceback (most recent call last):
File "/home/kulin/web2py/gluon/restricted.py", line 227, in restricted
exec ccode in environment
File "/home/kulin/web2py/applications/tester/controllers/default.py", line 143, in <module>
File "/home/kulin/web2py/gluon/globals.py", line 412, in <lambda>
self._caller = lambda f: f()
File "/home/kulin/web2py/gluon/tools.py", line 3583, in f
return action(*a, **b)
File "/home/kulin/web2py/applications/tester/controllers/default.py", line 50, in create_details
form = SQLFORM(db.post).process()
File "/home/kulin/web2py/gluon/html.py", line 2301, in process
self.validate(**kwargs)
File "/home/kulin/web2py/gluon/html.py", line 2238, in validate
if self.accepts(**kwargs):
File "/home/kulin/web2py/gluon/sqlhtml.py", line 1688, in accepts
self.vars.id = self.table.insert(**fields)
File "/home/kulin/web2py/gluon/packages/dal/pydal/objects.py", line 691, in insert
ret = self._db._adapter.insert(self, self._listify(fields))
File "/home/kulin/web2py/gluon/packages/dal/pydal/adapters/base.py", line 731, in insert
raise e
IntegrityError: FOREIGN KEY constraint failed
What am i doing wrong?

Massimo Di Pierro

unread,
Jul 8, 2015, 8:55:33 AM7/8/15
to web...@googlegroups.com, kulin...@gmail.com
what database are you using? did you ever change the field type?

kulin shah

unread,
Jul 9, 2015, 8:46:56 AM7/9/15
to web...@googlegroups.com

I am using the default SQLITE database. Yes I did change the field type couple of times back and forth since doing it list:reference auth_user was giving the same error. Basically I am making a notifier/tracker application for the test automation team much like the i-tracker app available on web2py website and the one that you have described in your videos. So I have a table which stores, among other things, a field called assigned_to that optionally takes i.e. is empty or is in db auth_user and is a single entry and this works perfectly. But now i also want to have another optional field of cc_list so that we can add more people in the cc for a particular task or let it remain empty. I also have an auth.signature on that table, don't know if that might be a reason for the error. So the foreign key error comes up when the form is submitted.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/IS5nViBP1TY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kulin shah

unread,
Jul 9, 2015, 8:46:56 AM7/9/15
to web...@googlegroups.com, kulin...@gmail.com
I am using the default SQLITE database. Yes I did change the field type couple of times back and forth since doing it list:reference auth_user was giving the same error. Basically I am making a notifier/tracker application for the test automation team much like the i-tracker app available on web2py website and the one that you have described in your videos. So I have a table which stores, among other things, a field called assigned_to that optionally takes i.e. is empty or is in db auth_user and is a single entry and this works perfectly. But now i also want to have another optional field of cc_list so that we can add more people in the cc for a particular task or let it remain empty. I also have an auth.signature on that table, don't know if that might be a reason for the error. So the foreign key error comes up when the form is submitted.

Reply all
Reply to author
Forward
0 new messages