#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)
Change History (13)
by , 19 years ago
Attachment: | sqlaccess.py added |
---|
comment:1 by , 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:3 by , 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:5 by , 19 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:6 by , 18 years ago
Cc: | added |
---|---|
Keywords: | eminem.com added |
Summary: | New SQL query API → eminem.com |
comment:9 by , 18 years ago
Cc: | added |
---|---|
Keywords: | eminem.com added |
Summary: | New SQL query API → eminem.com |
comment:10 by , 18 years ago
Summary: | eminem.com → New SQL query API |
---|
comment:11 by , 18 years ago
Cc: | added; removed |
---|---|
Keywords: | kakalu.com added; eminem.com removed |
Summary: | New SQL query API → kakalu.com |
comment:12 by , 18 years ago
Cc: | removed |
---|---|
Keywords: | kakalu.com removed |
Summary: | kakalu.com → New SQL query API |
Patch to proxy thd new SQL API to the old