Django ORM query syntax enhancement

2015-08-16 Thread Alexey Zankevich
Hi all, This topic is related to the current ORM query syntax with underscores. There are lots of arguing related to it, anyway it has pros and cons. Let's take a concrete example of querying a model: >>> GameSession.objects.filter(user__profile__last_login_date__gte=yesterday) Pros: 1. The

Re: Django ORM query syntax enhancement

2015-08-18 Thread Alexey Zankevich
sions rather than Q expressions: > > > > GameSession.objects.filter(Equal(Date(F.user.profile.last_login), > > datetime.now().date)) > > GameSession.objects.filter(E(F.user.profile.last_login).date() == > > datetime.now().date) > > > > I think it

Re: Django ORM query syntax enhancement

2015-08-18 Thread Alexey Zankevich
ngo. >> >> - Anssi >> >> >> >> On Tue, Aug 18, 2015 at 5:54 PM, Collin Anderson > > wrote: >> > Just a quick thought: I could imagine some newbies could get confused >> by the >> > python-like syntax and try to do: >>

Re: Django ORM query syntax enhancement

2015-08-20 Thread Alexey Zankevich
ents on the PR will go a long way > to helping me tidy it up sooner rather than later, so please feel free to > review. > > Regards, > > On Wednesday, 19 August 2015 04:55:21 UTC+10, Alexey Zankevich wrote: >> >> Once Josh completes this patch https://github.com/django/d

Re: Django ORM query syntax enhancement

2015-08-24 Thread Alexey Zankevich
ot;P." as a stand-in as you used previously. > > Supporting callables is an interesting idea, and I don't think that'll > cause issues with existing expressions. The callable must return an > expression though. If you wanted to write a patch to support callables, I'd

Re: Django ORM query syntax enhancement

2015-08-25 Thread Alexey Zankevich
t; metaclasses though. > > For what it's worth, the names `TreePath` and `FieldTree` are too low > level for a public facing API that is supposed to make it easier/safer to > craft field paths. One letter class names are also a bad design in general, > so we'd need something

Re: Django ORM query syntax enhancement

2015-08-26 Thread Alexey Zankevich
>> Contains(F.user.name, "Bob") # conflict Will work on another patch with custom class. On Tuesday, August 25, 2015 at 1:12:56 PM UTC+3, Alexey Zankevich wrote: > > Gotcha. > So, F objects seem to be pretty good as generic interface to specify query > paths, t

Django SQL templates

2015-08-27 Thread Alexey Zankevich
Hi all, After reading future of QuerySet.extra() discussion, I was thinking about the current custom ways to tweak SQL queries in Django. Firstly, it was the current .extra method, which everyone likely wants to get rid o

Re: Django ORM query syntax enhancement

2015-09-22 Thread Alexey Zankevich
. I'm talking about mentioned earlier syntax: GameSession.objects.filter(GreaterThan('user__profile__last_login_date', > yesterday)) > Could you give me a starter point for that? Thanks, Alexey On Wednesday, August 26, 2015 at 6:04:02 PM UTC+3, Alexey Zankevich wrote: > &

Re: Django ORM query syntax enhancement

2015-09-29 Thread Alexey Zankevich
x27;user__name', 'Bob') On Sunday, August 16, 2015 at 4:18:26 PM UTC+3, Alexey Zankevich wrote: > > Hi all, > > This topic is related to the current ORM query syntax with underscores. > There are lots of arguing related to it, anyway it has pros and cons. > > Le

Re: Django ORM query syntax enhancement

2015-09-30 Thread Alexey Zankevich
> expressions. > >>> > Func(Func(Func('field_name'))) is no issue. > >>> > > >>> > 3. Sounds like an OK idea, but I haven't looked into the details > enough > >>> > to > >>> > really comment. I do thi

Re: Django ORM query syntax enhancement

2015-09-30 Thread Alexey Zankevich
the > same sense. > > I think data__owner__other_pets__0__name is as nice to read as > JSONExtract('data', path=['owner', 'other_pets', 0, 'name']) personally. > > Marc > On 30 Sep 2015 5:13 pm, "Alexey Zankevich" > w

Re: Django ORM query syntax enhancement

2015-10-01 Thread Alexey Zankevich
gle argument transform or a left > and > >> right hand side lookup. > >> > >> In particular, I think your Decode(utf8) example is a good one. It > shows > >> that you could maybe shoehorn multiple arg transforms into the > >> __underscore__ ap

Re: Django ORM query syntax enhancement

2015-10-19 Thread Alexey Zankevich
concentrate on making expressions in filter calls and lookups as > expressions reality. When we have done that we can try out different > syntax approaches in 3rd party apps. Finally, after we have field > tested the approaches, we can merge something in to Django. > > - A

Re: Django ORM query syntax enhancement

2015-10-19 Thread Alexey Zankevich
I'm not sure about the extensions to F() just yet, I'm > hoping they aren't actually needed for your patch to work, but will need to > review to be sure. > > Cheers > > On Monday, 19 October 2015 21:49:37 UTC+11, Alexey Zankevich wrote: > > Hi all, &g

Re: Django ORM query syntax enhancement

2015-10-19 Thread Alexey Zankevich
> I'm > > hoping they aren't actually needed for your patch to work, but will need > to > > review to be sure. > > > > Cheers > > > > > > On Monday, 19 October 2015 21:49:37 UTC+11, Alexey Zankevich wrote: > >>

Re: Django ORM query syntax enhancement

2016-10-06 Thread Alexey Zankevich
ge=(d1, d2)) I think the library is at the final state now and isn't going to get new substantial features, but responses are highly appreciated. Regards, Alexey On Sunday, August 16, 2015 at 4:18:26 PM UTC+3, Alexey Zankevich wrote: > > Hi all, > > This topic is related to the current

Re: Django ORM query syntax enhancement

2016-10-12 Thread Alexey Zankevich
is approach to help making my queries more >> DRY. >> >> I also like how lightweight the library is altogether. Well done! >> >> >> For those looking for a direct link, here you go: >> https://github.com/Nepherhotep/django-orm-sugar >> >> >&

Re: Django ORM query syntax enhancement

2017-03-31 Thread Alexey Zankevich
gt;> In []: -F.user.created >> Out[]: OrderBy(FExpr(user__created), descending=True) >> >> In []: F.text.iexact('...') >> Out[]: >> >> >> >> >> On Thursday, October 6, 2016 at 10:04:56 AM UTC-7, Alexey Zan