Oh no!,no!,no! please no!
I still hope it's my mistake only. I simple cannot believe, that this
is behaviour of web2py data model. Are we in year 1960?
Friends, take a look to the oldest database implementations older as
SQL language, in MS-DOS times, f.e. dBase III, FoxBase, Clipper. And
earlier on the mainframes this was sure known and allowed too.
There were NEVER problems with such type of foreign keys! If we have
model with 5 tables, maybe we can avoid use of such foreign keys,
however if we have a realy bussiness application with about 50 tables?

I know I'm beginner here, however I have choosen web2py as a world
leading and best designed framework. Should I find somewhere else? Has
Django same basic problems with data model?

Or is there a workaround in web2py?
I have idea about 2 possible ways:


1)
Can I patch web2py to disable call of _create_references() after
separate table is added to the model? _create_references() are then to
be called after all tables are already added, in cycle through all
tables in the model.
However, this way is more for web2py authors as for me...


2)
Can I use standard 'integers' for foreign keys instead of
'reference..'?

I know that 'reference...' takes care for referential integrity. I
don't know, if cascade deleting is implemented on the web2py level or
on the database backend level. However, I think, this is one thing,
which is unusable in current implementation: Because OnDelete=Nothing
is unusable at all (breakes referential integrity), and
OnDelete=Cascade is not enough. Implementation of OnDelete=SetNull/
None is necessary -- so this is first point which I have to solve
regardless if I will use 'reference..' or 'integer' types.

And second problem is the widget for foreign key (for SQLFORM & Crud),
however I think I can assign same widget for 'integer' as for
'reference..'?

Is there something more, where 'reference..' type works better as
'integer'?

Thanks for responses and help.
Mirek


> > db.define_table('company',
> >    Field('name'),
> >    Field('created_by', 'reference person'))
> > db.define_table('person',
> >    Field('last_name'),
> >    Field('company_id', 'reference company'))
> > but I receive error:
> >  File "C:\Python27\Lib\site-packages\web2py\gluon\sql.py", line 1643,
> > in _create_references
> >    raise SyntaxError, 'Table: table "%s" does not exist' % referenced

Reply via email to