An ugly work around seems to be to add a fake id field to the view's definition using something like abs(random()). It worked on the one view I tried, but it isn't guaranteed to since random does not guarantee unique every time. It would be nice to just be able to tell the DAL this is a view and not have it worry about an id and also have the DAL know that it should only let you select from the view and not try to insert stuff. That'd require changes to the DAL though, so I guess db.executesql() is probably the best answer for now.
~Brian On Nov 13, 4:36 pm, Brian M <bmere...@gmail.com> wrote: > They are SQLite views, though I suspect you'd have similar problems > with other database's views as well. > > There is no auto-increment field at all - it's a database view rather > than a table. Having an auto-increment field doesn't make any sense in > a view, you're not going to insert any records into a view. These are > views that do things like summarize data from multiple tables. > > ~Brian > > On Nov 13, 1:44 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > Do they have an autoincrement integer field, even if not called id? > > what database? > > > On Nov 13, 1:31 pm, Brian M <bmere...@gmail.com> wrote: > > > > Is there a way to work with database views using the DAL? I've got a > > > bunch of views in my database that handle common queries, but I'm not > > > seeing a way to use them with the DAL since they don't have an id > > > field. I tried to define a DAL "table" with the same fields as the > > > view and just set it to migrate=False, since I don't want the table to > > > be created, but from the Admin every query against the view is an > > > "Invalid Query". Is db.executesql() the only option? > > > > ~Brian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---