Issue with DAL reference fields

39 views
Skip to first unread message

Anthony

unread,
Mar 30, 2017, 12:09:03 PM3/30/17
to web2py-developers
Please read this comment and following on Github: https://github.com/web2py/pydal/issues/258#issuecomment-290439396

The question is whether we should allow a DAL reference field to be defined when the table it references has not yet been defined. Currently, this does not work unless lazy=True, which technically is a break of backward compatibility, as noted in the thread linked in my comment. On the other hand, it seems it has been broken for a long time, so maybe it's not a big deal.

As noted in my later comment, this isn't just an issue of proper database design, as in some cases, you might want to forego definitions of linked tables for efficiency purposes when they are not needed for the current request. Again, though, that's probably not a critical use case, so we could probably just live with the current behavior.

Anthony

Paolo Valleri

unread,
Mar 30, 2017, 1:03:17 PM3/30/17
to web2py-d...@googlegroups.com
We discussed this issue few times. See for example https://groups.google.com/forum/#!topic/web2py-developers/ZnqC0GZiTd8/discussion
I've also proposed a 'potential' solution, see https://github.com/ilvalle/pydal/tree/deferred-references

 Paolo

--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Vézina

unread,
Mar 30, 2017, 2:07:56 PM3/30/17
to web2py-d...@googlegroups.com
I leave a comment on the issue : https://github.com/web2py/pydal/issues/258#issuecomment-290439396

I would say also that you may want that referenced table don't get systematically defined when lazy=True particularilly for situation where you had customized auth tables. In my case I have a address/phone directory in my app. I use to reference address table from auth_user table, but there is like 5-7 table that get define because of that, since all address phone number city contry etc get define when auth_user is defined which pretty much at every request if you use auth, so...

I am not sure if it make sens, but we could maybe have lazy_field??

Richard

Richard Vézina

unread,
Mar 30, 2017, 5:17:59 PM3/30/17
to web2py-d...@googlegroups.com
@Anthony, For some reason I can't wrote about the last comment on the issue on github, after the one I made.

I am aware of the disucssion you talk about. Understand the issue, at least the issue of not having proper constraint define in the backend. My understand was that it would bring the DAL at complete other level as something between a DAL and an ORM if we start to differ model definition as circular reference would require...

At least I think we can properly explain workaround to the actual situation, something like : If you want to use circular reference be notice that DAL don't support proper model definition for xyz technical considation, so you have to make sure you create the fk contraint in the back end of trick the DAL by defining once your circular model without referenciation and add them later once both model have been created in the database, so web2py should be able to alter model table and add proper fk constraint...

Hope I am right thing such a workaround would work as I didn't tested it before posting it here.

Richard


Richard Vézina

unread,
Mar 30, 2017, 5:19:09 PM3/30/17
to web2py-d...@googlegroups.com
Also, if we don't want to fix it, we may leave a issue with an "won't fix" flag for further discussion and bind everything we can over it so our reflexion won't get lost.

Richard
Reply all
Reply to author
Forward
0 new messages