Sunday, June 20, 2010

Proposed API Change (DAL)

Hi All,

The Query interface of the DAL API is going to be changed in next version to make it compatible with Google App Engine as GAE doesn't support OR operator. However, the IN operator can provide limited OR support.

Also the Query.filter would be changed to follow GAE's Query.filter signature. The OR and NOT IN operators are not supported in GAE, but the DAL API would implement support for these operators.

So, the following syntax:
Query(User).filter('name = :name and age >= :age', name='some', age=18)
will be replace with:
Query(User).filter('name =', 'some').filter('age >=', 18)
Support of OR operator will implemented as || operator, like:
from kalapy.db import Query, Q

Query(User).filter(Q('name =', 'some') || Q('age >=', 18))
The operator NOT IN would be expanded to (only GAE):
Query(User).filter('name not in', ['some', 'thing', 'else'])

# to

Query(User).filter('name !=', 'some') \
           .filter('name !=', 'thing') \
           .filter('name !=', 'else')
Currently, PostgreSQL and SQLite3 backend engines are implemented. Development is in progress to add support for Google App Engine and OpenERP.

Stay Tuned!

0 comments: