django-postgres-lookups-any
Provides =ANY(ARRAY(xxx)) instead of IN (xxx)
Documentation
This library is designed for Postgres. It enables developers to cope with problem when Postgres doesn’t use indexes with long IN () statements.
Usually, when you try to do a query:
SELECT a.* FROM a
WHERE a.id NOT IN (
SELECT b.id FROM b
)
You expect that it will be used index on a.id. Unfortunately, it doesn’t work.
There is a trick to make Postgres do it by rewritten query this way:
SELECT a.* FROM a
WHERE a.id=ANY(ARRAY(SELECT b.id FROM b))
This library allows you to use this statement. Examples:
"""
SELECT * FROM mymodel WHERE somefield=ANY([1, 2, 3])
"""
MyModel.objects.filter(somefield__any_arr=[1, 2, 3])
"""
SELECT * FROM mymodel WHERE somefield=ANY(ARRAY(SELECT somefield FROM modelb))
"""
subquery = Subquery(model_b__instances.values('somefield'))
MyModel.objects.filter(somefield__any=subquery)
Quickstart
Install django-postgres-lookups-any:
pip install django-postges-lookups-any
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'django_postges_lookups_any',
...
)
Running Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install -r requirements_test.txt (myenv) $ pytest
Development commands
pip install -r requirements_dev.txt
Credits
Tools used in rendering this package:
History
0.1.0 (2021-02-08)
First release on PyPI.
Metadata
Release files for django-postges-lookups-any 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-postges-lookups-any-0.1.2.tar.gz | 8.4 kB | Without provenance | Details for django-postges-lookups-any-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_postges_lookups_any-0.1.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for django_postges_lookups_any-0.1.2-py2.py3-none-any.whl |
Total release size: 16.4 kB
Release files / django-postges-lookups-any-0.1.2.tar.gz
| Download URL | django-postges-lookups-any-0.1.2.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
94ade79ad51b391e8968b05772c2cffb2ad4b7c78bc645f9eb6a3986459d6cea
|
|
BLAKE2b-256 checksum How to use checksums |
65799b9fa5acf43338ec281bd9f4e5467c6890a54d09e04e9b21427b463a1b67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
|
Release files / django_postges_lookups_any-0.1.2-py2.py3-none-any.whl
| Download URL | django_postges_lookups_any-0.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
626df8a3d75deaf5f55d8f9cf3a33c2cd9c54207c7b2dca3f796045f73d15102
|
|
BLAKE2b-256 checksum How to use checksums |
ec332df945358115eebee8a4c6208fb0f56c67b2327be2ffa410308c813462a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
|
Security for django-postges-lookups-any 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.