Opened 19 years ago

Closed 19 years ago

Last modified 17 years ago

#851 closed enhancement (invalid)

New SQL query API

Reported by: aaronsw Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm not sure how to put this nicely, but Django's SQL query API is pretty bad. I remember excitedly thinking of switching my project to Django and then seeing this terrible syntax and just giving up entirely. Indeed, I probably would never give Django a second look if I hadn't had lunch with Adrian. pub_datedatelte='2005-01-01' is not just unintuitive, it's ugly.

Attachments (1)

sqlaccess.py (3.2 KB ) - added by aaronsw 19 years ago.
Patch to proxy thd new SQL API to the old

Download all attachments as: .zip

Change History (13)

by aaronsw, 19 years ago

Attachment: sqlaccess.py added

Patch to proxy thd new SQL API to the old

comment:1 by anonymous, 19 years ago

The attachment is a Python module that implements the a new SQL syntax. Instead of pub_date__date__lte='2005-01-01' you simply write q.pub_date <='2005-01-01'; you can also combine things using '&' and '|', although I don't know how to map these into existing Django. The way this would work is that the q object would be added to the default list of vars that currently includes things like datetime. Django tables would be replaced with something like the Table object in this function.

Note that this API also cuts down on the dozens of get_suchandsuch() functions. .get() returns one function which is an iterator, a list, a get_object, and so on in the appropriate contexts.

comment:2 by hugo, 19 years ago

see also #251 for & and | combination of queries

comment:3 by rjwittams, 19 years ago

I see can see the need for a better query api - something like hibernates HQL, which allows you to query things in a very flexible way. This would be implemented by creating an AST that can be transformed by backends into appropriate SQL - this would allow cleanly supporting SQL Server wierdness, and even non sql databases.

The existing query stuff should be done on top of a more flexible system rather than the other way round. However, I think this is something for 2.0.

comment:4 by hugo, 19 years ago

see also #980 for a similar approach

comment:5 by Adrian Holovaty, 19 years ago

Resolution: invalid
Status: newclosed

comment:6 by buy flextra, 18 years ago

Cc: eminem.com added
Keywords: eminem.com added
Summary: New SQL query APIeminem.com

comment:7 by Adrian Holovaty, 18 years ago

Summary: eminem.comNew SQL query API

Reverted spam.

comment:8 by Adrian Holovaty, 18 years ago

Cc: eminem.com removed
Keywords: eminem.com removed

More spam reverting.

comment:9 by (none), 18 years ago

Cc: eminem.com added
Keywords: eminem.com added
Summary: New SQL query APIeminem.com

comment:10 by Adrian Holovaty, 18 years ago

Summary: eminem.comNew SQL query API

comment:11 by male fertility problem, 18 years ago

Cc: kakalu.com added; eminem.com removed
Keywords: kakalu.com added; eminem.com removed
Summary: New SQL query APIkakalu.com

comment:12 by anonymous, 18 years ago

Cc: kakalu.com removed
Keywords: kakalu.com removed
Summary: kakalu.comNew SQL query API
Note: See TracTickets for help on using tickets.
Back to Top