[Zope3-dev] Re: I want Object Gadfly

Evan Simpson evan@4-am.com
Fri, 18 Jul 2003 14:46:31 -0500


Jim Fulton wrote:
> No:
> 
> INSERT INTO user_links values (
>   ob1, ob2
>   user,
>   10
> );
> 
> BTW, I'm less interested in DML than in queries.

After thinking about it a bit, I've formed the opinion that everything 
except queries (DML, UPDATE, DELETE, INSERT) should probably be done 
through an API rather than parsed SQL statements.  In your 
counter-example, it's not at all clear to me where 'ob1' and 'ob2' come 
from, while I would have no qualms at all if it were Python:

ogdb.insert('user_links', fields=None, values=(ob1, ob2, user, 10))

If the query system can return row objects, not just result data, then 
UPDATE and DELETE are straightforward (more so than SQL, in some cases):

for r in ogdb.select_rows('FROM table1, table2 WHERE '+
                           complex_query_string):
     r['table1'].delete()
     r['table2']['mol'] = 42

I've always found this sort of thing to be very painful to construct as 
SQL using DTML, despite all of the special-purpose dtml-sql commands.

We'd still need a way to bind names when invoking a query, to make 
turning an object reference into a string and back again as simple as 
possible:

ogdb.select('SELECT * FROM user_links WHERE subject=ob1',
             ob1=container.fred)

> I'm definately waving my hands a bit. :)

I'm waving back :-)

Cheers,

Evan @ 4-am