You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
The key has expired.
0.10.4
✨ Features
Add Python style to filter and order_by with field access instead of dunder separated strings. #51
Accessing a field with attribute access (chain of dot notation) can be used to construct FilterGroups (ormar.and_ and ormar.or_)
Field access overloads set of python operators and provide a set of functions to allow same functionality as with dunder separated param names in **kwargs, that means that querying from sample model Track related to model Album now you have more options:
exact - exact match to value, sql column = <VALUE>
OLD: album__name__exact='Malibu'
NEW: can be also written as Track.album.name == 'Malibu
iexact - exact match sql column = <VALUE> (case insensitive)
OLD: album__name__iexact='malibu'
NEW: can be also written as Track.album.name.iexact('malibu')
contains - sql column LIKE '%<VALUE>%'
OLD: album__name__contains='Mal'
NEW: can be also written as Track.album.name % 'Mal')
NEW: can be also written as Track.album.name.contains('Mal')
icontains - sql column LIKE '%<VALUE>%' (case insensitive)
OLD: album__name__icontains='mal'
NEW: can be also written as Track.album.name.icontains('mal')
in - sql column IN (<VALUE1>, <VALUE2>, ...)
OLD: album__name__in=['Malibu', 'Barclay']
NEW: can be also written as Track.album.name << ['Malibu', 'Barclay']
NEW: can be also written as Track.album.name.in_(['Malibu', 'Barclay'])
isnull - sql column IS NULL (and sql column IS NOT NULL)
You can of course also combine different models and many order_bys: Product.objects.order_by([Product.category.name.asc(), Product.name.desc()]).all()
🐛 Fixes
Not really a bug but rather inconsistency. Providing a filter with nested model i.e. album__category__name = 'AA'
is checking if album and category models are included in select_related() and if not it's auto-adding them there.
The same functionality was not working for FilterGroups (and_ and or_), now it works (also for python style filters which return FilterGroups).