This seems to be a problematic FAQ, but: if I'm making an effort to
normalize my database structure how do I do cross-table validation?
Example (with extraneous things left out):
db.define_table('competitions',
SQLField('name','string'),
SQLField('chief_ref','string'))
db.competitions.name.requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB
(db,'competitions.name')]
db.define_table('events',
SQLField('name','string',length=64),
SQLField('competition',db.competitions))
db.events.competition.requires=IS_IN_DB
(db,'competitions.id','competitions.name')
I want to assure that newly added events meet the constraint that the
combination of events.name+competitions.id is unique. IOW, I don't
want two events with the same name for a specific competition.
In this simple case I think I can solve it by means discussed here
previously, But still, I would think cross-table validation is a very
frequent requirement in real applications that there should be some
sugar for it, no?
If you use a carefully normalized schema the number of cross-table
validations requirements grows beyond just two. And in real
"enterprise" applications, wouldn't you even need to do cross-DB
validations?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---