Re: Model.objects.raw() (#11863)

2009-11-18 Thread SeanOC
I've posted a new patch to the ticket (http://code.djangoproject.com/ ticket/11863) and have pushed my latest code to http://github.com/SeanOC/django/tree/ticket11863. All of the issues which Jacob raised should now be resolved and an initial version of caching the query results has been implement

Re: Model.objects.raw() (#11863)

2009-10-05 Thread James Bennett
On Fri, Oct 2, 2009 at 9:37 AM, Russell Keith-Magee wrote: > Django's ORM is designed to make the simple cases really simple, but > once you move beyond the basics, you really should be looking to use > raw SQL. Indeed. I look at raw() really as "I know *exactly* the query I want to run, get the

Re: Model.objects.raw() (#11863)

2009-10-05 Thread mrts
On Oct 2, 7:35 pm, mrts wrote: > But let me stop right here. Contradicting myself, I've pursued this further and implemented raw_override() for order_by in [1] as a proof of concept. See [2] for what's different and tests [3] for usage. I'd say that for order_by, the implementation is simple an

Re: Model.objects.raw() (#11863)

2009-10-02 Thread mrts
On Oct 2, 5:42 pm, "Sean O'Connor" wrote: > To be honest this seems like something which would be a lot of work with > relatively little gain.  For this to work raw() would need to change from a > relatively simple bit of code which doesn't need to touch all of the complex > query code in the ORM

Re: Model.objects.raw() (#11863)

2009-10-02 Thread Sean O'Connor
To be honest this seems like something which would be a lot of work with relatively little gain. For this to work raw() would need to change from a relatively simple bit of code which doesn't need to touch all of the complex query code in the ORM to a complex bit of code which needs to deeply modi

Re: Model.objects.raw() (#11863)

2009-10-02 Thread Russell Keith-Magee
On Fri, Oct 2, 2009 at 7:35 PM, mrts wrote: > > Wishful thinking follows. > > It would be awesome if one could mix ordinary QuerySet methods > with raw() (or, rather, raw_extra(), see below for that). While I can see what you're aiming at here, I'm not really a fan of the idea. Django's ORM is

Re: Model.objects.raw() (#11863)

2009-10-02 Thread Rajeev J Sebastian
On Tue, Sep 29, 2009 at 6:54 AM, SeanOC wrote: > > Hello All, > > During the Djangocon sprints I started to work on a patch which would > add a nicer interface for dealing with raw SQL queries.  While there I > talked to RKM about where it should fit into the ORM API and where in > the code base

Re: Model.objects.raw() (#11863)

2009-10-02 Thread mrts
Wishful thinking follows. It would be awesome if one could mix ordinary QuerySet methods with raw() (or, rather, raw_extra(), see below for that). Assuming the following models: class Foo(models.Model): name = models.CharField(max_length=255) class FooDates(models.Model): foo = models.

Re: Model.objects.raw() (#11863)

2009-09-29 Thread SeanOC
> The first is that I'd like it to be compatible with deferred loading > of model attributes - I haven't looked in to it, but my hunch is that > this won't be too hard (it might even work in its present form without > any further changes). The current implementation doesn't support this. It wil

Re: Model.objects.raw() (#11863)

2009-09-29 Thread Simon Willison
On Sep 29, 2:24 am, SeanOC wrote: > During the Djangocon sprints I started to work on a patch which would > add a nicer interface for dealing with raw SQL queries.  While there I > talked to RKM about where it should fit into the ORM API and where in > the code base should live.  I've finally got

Re: Model.objects.raw() (#11863)

2009-09-29 Thread Jeremy Dunck
On Tue, Sep 29, 2009 at 4:30 AM, Russell Keith-Magee wrote: ... > This trick is exactly what Django does internally when it constructs > object instances. However, in the Django internals, it is a completely > automated process - Django issues the query and parses the results, so > there's no ris

Re: Model.objects.raw() (#11863)

2009-09-29 Thread Russell Keith-Magee
On Tue, Sep 29, 2009 at 4:27 PM, David Reynolds wrote: > > Russ, > > On 29 Sep 2009, at 03:25, Russell Keith-Magee wrote: > >>  (1) know about the trick of instantiating an object with the >> unrolled list version of a cursor, and > > > Any chance you could expand upon this? Sure. Assume a simpl

Re: Model.objects.raw() (#11863)

2009-09-29 Thread Simon Willison
On Sep 29, 2:24 am, SeanOC wrote: > During the Djangocon sprints I started to work on a patch which would > add a nicer interface for dealing with raw SQL queries.  While there I > talked to RKM about where it should fit into the ORM API and where in > the code base should live.  I've finally got

Re: Model.objects.raw() (#11863)

2009-09-29 Thread David Reynolds
Russ, On 29 Sep 2009, at 03:25, Russell Keith-Magee wrote: > (1) know about the trick of instantiating an object with the > unrolled list version of a cursor, and Any chance you could expand upon this? -- David Reynolds da...@reynoldsfamily.org.uk --~--~-~--~~~---

Re: Model.objects.raw() (#11863)

2009-09-28 Thread Eric Florenzano
> So my question, and this is something I've been thinking about a lot > of the proposals lately is: why should this be in Django itself. I couldn't agree with your sentiment more, in the whole. In fact, to me, until now all of the proposals aside from Simon's seem better outside of Django than

Re: Model.objects.raw() (#11863)

2009-09-28 Thread Russell Keith-Magee
On Tue, Sep 29, 2009 at 9:29 AM, Alex Gaynor wrote: > > On Mon, Sep 28, 2009 at 9:24 PM, SeanOC wrote: >> >> Hello All, >> >> During the Djangocon sprints I started to work on a patch which would >> add a nicer interface for dealing with raw SQL queries.  While there I >> talked to RKM about whe

Re: Model.objects.raw() (#11863)

2009-09-28 Thread Alex Gaynor
On Mon, Sep 28, 2009 at 9:24 PM, SeanOC wrote: > > Hello All, > > During the Djangocon sprints I started to work on a patch which would > add a nicer interface for dealing with raw SQL queries.  While there I > talked to RKM about where it should fit into the ORM API and where in > the code base