-
Notifications
You must be signed in to change notification settings - Fork 106
django-postgres-extra with support for Django 5+ #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MONSTER-HARSH
wants to merge
2
commits into
SectorLabs:master
Choose a base branch
from
opencodenest:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,89 @@ | ||
# django-pg-extra-extended (Fork for Django 5+) | ||
|
||
<h1 align="center"> | ||
<img width="400" src="https://i.imgur.com/79S6OVM.png" alt="django-postgres-extra"> | ||
</h1> | ||
|
||
|
||
This is a fork of `django-postgres-extra`, updated to support Django 5+ while maintaining PostgreSQL enhancements for the Django ORM. | ||
|
||
| | | | | ||
|--------------------|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| :white_check_mark: | **Tests** | [](https://circleci.com/gh/SectorLabs/django-postgres-extra/tree/master) | | ||
| :memo: | **License** | [](http://doge.mit-license.org) | | ||
| :package: | **PyPi** | [](https://pypi.python.org/pypi/django-postgres-extra) | | ||
| :four_leaf_clover: | **Code coverage** | [](https://coveralls.io/github/SectorLabs/django-postgres-extra?branch=master) | | ||
| <img src="https://cdn.iconscout.com/icon/free/png-256/django-1-282754.png" width="22px" height="22px" align="center" /> | **Django Versions** | 2.0, 2.1, 2.2, 3.0, 3.1, 3.2, 4.0, 4.1, 4.2, 5.0 | | ||
| <img src="https://cdn3.iconfinder.com/data/icons/logos-and-brands-adobe/512/267_Python-512.png" width="22px" height="22px" align="center" /> | **Python Versions** | 3.6, 3.7, 3.8, 3.9, 3.10, 3.11 | | ||
| :package: | **PyPi** | (Coming soon) | | ||
| <img src="https://cdn.iconscout.com/icon/free/png-256/django-1-282754.png" width="22px" height="22px" align="center" /> | **Django Versions** | 5.0+ | | ||
| <img src="https://cdn3.iconfinder.com/data/icons/logos-and-brands-adobe/512/267_Python-512.png" width="22px" height="22px" align="center" /> | **Python Versions** | 3.8, 3.9, 3.10, 3.11, 3.12 | | ||
| <img src="https://pbs.twimg.com/profile_images/1152122059/psycopg-100_400x400.png" width="22px" height="22px" align="center" /> | **Psycopg Versions** | 2, 3 | | ||
| :book: | **Documentation** | [Read The Docs](https://django-postgres-extra.readthedocs.io/en/master/) | | ||
| :warning: | **Upgrade** | [Upgrade from v1.x](https://django-postgres-extra.readthedocs.io/en/master/major_releases.html#new-features) | ||
| :checkered_flag: | **Installation** | [Installation Guide](https://django-postgres-extra.readthedocs.io/en/master/installation.html) | | ||
| :fire: | **Features** | [Features & Documentation](https://django-postgres-extra.readthedocs.io/en/master/index.html#features) | | ||
| :droplet: | **Future enhancements** | [Potential features](https://github.com/SectorLabs/django-postgres-extra/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement) | | ||
|
||
`django-postgres-extra` aims to make all of PostgreSQL's awesome features available through the Django ORM. We do this by taking care of all the hassle. As opposed to the many small packages that are available to try to bring a single feature to Django with minimal effort. ``django-postgres-extra`` goes the extra mile, with well tested implementations, seamless migrations and much more. | ||
|
||
With seamless we mean that any features we add will work truly seamlessly. You should not have to manually modify your migrations to work with fields and objects provided by this package. | ||
|
||
--- | ||
|
||
:warning: **This README is for v2. See the `v1` branch for v1.x.** | ||
|
||
--- | ||
|
||
## Major features | ||
| :book: | **Documentation** | (Coming soon) | | ||
| :fire: | **Features** | [Features & Documentation](https://github.com/MONSTER-HARSH/django-pg-extra-extended/) | | ||
| :droplet: | **Future enhancements** | [Potential features](https://github.com/MONSTER-HARSH/django-pg-extra-extended/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement) | | ||
|
||
[See the full list](http://django-postgres-extra.readthedocs.io/#features) | ||
## About | ||
|
||
* **Native upserts** | ||
This fork of `django-postgres-extra` extends support for Django 5+, keeping all the powerful PostgreSQL features, including: | ||
|
||
* Single query | ||
* Concurrency safe | ||
* With bulk support (single query) | ||
- **Native upserts** with bulk support | ||
- **Extended support for HStoreField** (unique constraints, null constraints, etc.) | ||
- **Declarative table partitioning** for PostgreSQL 11+ | ||
- **Faster deletes** using table truncation | ||
- **Advanced indexing options** (conditional and case-sensitive unique indexes) | ||
|
||
* **Extended support for HStoreField** | ||
## Installation | ||
|
||
* Unique constraints | ||
* Null constraints | ||
* Select individual keys using ``.values()`` or ``.values_list()`` | ||
Coming soon to PyPI. | ||
|
||
* **PostgreSQL 11.x declarative table partitioning** | ||
For now, install directly from GitHub: | ||
|
||
* Supports both range and list partitioning | ||
```sh | ||
pip install git+https://github.com/MONSTER-HARSH/django-pg-extra-extended.git | ||
``` | ||
|
||
* **Faster deletes** | ||
## Getting Started | ||
|
||
* Truncate tables (with cascade) | ||
|
||
* **Indexes** | ||
|
||
* Conditional unique index. | ||
* Case sensitive unique index. | ||
|
||
## Working with the code | ||
### Prerequisites | ||
1. Clone the repository: | ||
|
||
* PostgreSQL 10 or newer. | ||
* Django 2.0 or newer (including 3.x, 4.x). | ||
* Python 3.6 or newer. | ||
```sh | ||
git clone https://github.com/MONSTER-HARSH/django-pg-extra-extended.git | ||
``` | ||
|
||
### Getting started | ||
2. Create a virtual environment: | ||
|
||
1. Clone the repository: | ||
```sh | ||
cd django-pg-extra-extended | ||
python -m venv env | ||
source env/bin/activate | ||
``` | ||
|
||
λ git clone https://github.com/SectorLabs/django-postgres-extra.git | ||
3. Create a PostgreSQL user for testing: | ||
|
||
2. Create a virtual environment: | ||
```sh | ||
createuser --superuser psqlextra --pwprompt | ||
export DATABASE_URL=postgres://psqlextra:<password>@localhost/psqlextra | ||
``` | ||
|
||
λ cd django-postgres-extra | ||
λ virtualenv env | ||
λ source env/bin/activate | ||
4. Install dependencies: | ||
|
||
3. Create a postgres user for use in tests (skip if your default user is a postgres superuser): | ||
```sh | ||
pip install .[test] .[analysis] | ||
``` | ||
|
||
λ createuser --superuser psqlextra --pwprompt | ||
λ export DATABASE_URL=postgres://psqlextra:<password>@localhost/psqlextra | ||
5. Run tests: | ||
|
||
Hint: if you're using virtualenvwrapper, you might find it beneficial to put | ||
the ``export`` line in ``$VIRTUAL_ENV/bin/postactivate`` so that it's always | ||
available when using this virtualenv. | ||
```sh | ||
tox | ||
``` | ||
|
||
4. Install the development/test dependencies: | ||
## Migration from Original django-postgres-extra | ||
|
||
λ pip install .[test] .[analysis] | ||
If you're upgrading from `django-postgres-extra` (SectorLabs version), ensure that: | ||
|
||
5. Run the tests: | ||
- You update the package source to this fork. | ||
- You check for any API changes due to Django 5+ compatibility adjustments. | ||
|
||
λ tox | ||
## Contributing | ||
|
||
6. Run the benchmarks: | ||
Contributions are welcome! Please open an issue or submit a pull request. | ||
|
||
λ py.test -c pytest-benchmark.ini | ||
## License | ||
|
||
7. Auto-format code, sort imports and auto-fix linting errors: | ||
MIT License. See [LICENSE](LICENSE) for details. | ||
|
||
λ python setup.py fix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +0,0 @@ | ||
import django | ||
|
||
from ._version import __version__ | ||
|
||
if django.VERSION < (3, 2): # pragma: no cover | ||
default_app_config = "psqlextra.apps.PostgresExtraAppConfig" | ||
|
||
__all__ = [ | ||
"default_app_config", | ||
"__version__", | ||
] | ||
else: | ||
__all__ = [ | ||
"__version__", | ||
] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you mean to commit this.
There are a lot of things in this commit, that you should go over, for starters, CI is broken, can you get that fixed?