Skip to content

Commit 5b8ef9e

Browse files
committed
Warn in the documentation that some features are native in newer Django versions
1 parent 35ed1d2 commit 5b8ef9e

File tree

4 files changed

+63
-32
lines changed

4 files changed

+63
-32
lines changed

README.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,35 @@ With seamless we mean that any features we add will work truly seamlessly. You s
3131

3232
[See the full list](http://django-postgres-extra.readthedocs.io/#features)
3333

34-
* **Native upserts**
34+
* **Conflict handling (atomic upsert)**
3535

36-
* Single query
37-
* Concurrency safe
38-
* With bulk support (single query)
36+
Add support for PostgreSQL's `ON CONFLICT` syntax for inserts. Supports `DO UPDATE` and `DO NOTHING`. Single statement, atomic and concurrency safe upserts. Supports conditional updates as well.
3937

40-
* **Extended support for HStoreField**
38+
* **Table partitioning**
4139

42-
* Unique constraints
43-
* Null constraints
44-
* Select individual keys using ``.values()`` or ``.values_list()``
40+
Add support for PostgreSQL 11.x declarative table partitioning. Fully integrated into Django migrations. Supports all types of partitioning. Includes a command to automatically create time-based partitions.
4541

46-
* **PostgreSQL 11.x declarative table partitioning**
42+
* **Locking models & tables**
4743

48-
* Supports both range and list partitioning
44+
Support for explicit table-level locks.
4945

50-
* **Faster deletes**
46+
* **Creating/dropping schemas**
5147

52-
* Truncate tables (with cascade)
48+
Support for managing PostgreSQL schemas.
5349

54-
* **Indexes**
50+
* **Truncating tables**
5551

56-
* Conditional unique index.
57-
* Case sensitive unique index.
52+
Support for ``TRUNCATE TABLE`` statements (including cascading).
53+
54+
For Django 3.1 and older:
55+
56+
* **Conditional unique index**
57+
* **Case insensitive index**
58+
59+
For Django 2.2 and older:
60+
61+
* **Unique index**
62+
* **HStore unique and required constraints on specific HStore keys**
5863

5964
## Working with the code
6065
### Prerequisites

docs/source/hstore.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ Constraints
1515
Unique
1616
******
1717

18+
.. warning::
19+
20+
In Django 2.2 or newer, you might want to use :class:`~django.db.models.UniqueConstraint` instead.
21+
1822
The ``uniqueness`` constraint can be added on one or more `hstore`_ keys, similar to how a ``UNIQUE`` constraint can be added to a column. Setting this option causes unique indexes to be created on the specified keys.
1923

2024
You can specify a ``list`` of strings to specify the keys that must be marked as unique:
@@ -44,6 +48,10 @@ In the example above, ``key1`` and ``key2`` must unique **together**, and ``key3
4448
Required
4549
********
4650
51+
.. warning::
52+
53+
In Django 2.2 or newer, you might want to use :class:`~django.db.models.CheckConstraint` instead.
54+
4755
The ``required`` option can be added to ensure that the specified `hstore`_ keys are set for every row. This is similar to a ``NOT NULL`` constraint on a column. You can specify a list of `hstore`_ keys that are required:
4856
4957
.. code-block:: python

docs/source/index.rst

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,43 @@ Explore the documentation to learn about all features:
1313

1414
* :ref:`Conflict handling <conflict_handling_page>`
1515

16-
Adds support for PostgreSQL's ``ON CONFLICT`` syntax for inserts. Supports for ``DO UPDATE`` and ``DO NOTHING``. In other words; single statement, atomic, concurrency safe upserts.
16+
Adds support for PostgreSQL's ``ON CONFLICT`` syntax for inserts. Supports for ``DO UPDATE`` and ``DO NOTHING``. Single statement, atomic, concurrency safe upserts. Supports conditional updates as well.
1717

18-
* :ref:`HStore <hstore_page>`
19-
20-
Built on top Django's built-in support for `hstore`_ fields. Adds support for indices on keys and unique/required constraints. All of these features integrate well with Django's migrations sytem.
18+
* :ref:`Table partitioning <table_partitioning_page>`
2119

22-
* :ref:`Partial unique index <conditional_unique_index_page>`
20+
Add support for PostgreSQL 11.x declarative table partitioning. Fully integrated into Django migrations. Supports all types of partitioning. Includes a command to automatically create time-based partitions.
2321

24-
Partial (unique) index that only applies when a certain condition is true.
25-
26-
* :ref:`Case insensitive index <case_insensitive_unique_index_page>`
22+
* :ref:`Locking models & tables <locking_page>`
2723

28-
Case insensitive index, allows searching a column and ignoring the casing.
24+
Support for explicit table-level locks.
2925

30-
* :ref:`Table partitioning <table_partitioning_page>`
26+
* :ref:`Creating/dropping schemas <schemas_page>`
3127

32-
Adds support for PostgreSQL 11.x declarative table partitioning.
28+
Support for managing Postgres schemas.
3329

3430
* :ref:`Truncating tables <truncate_page>`
3531

3632
Support for ``TRUNCATE TABLE`` statements (including cascading).
3733

38-
* :ref:`Locking models & tables <locking_page>`
34+
For Django 3.1 and older:
3935

40-
Support for explicit table-level locks.
36+
* :ref:`Partial unique index <conditional_unique_index_page>`
4137

38+
Partial (unique) index that only applies when a certain condition is true.
4239

43-
* :ref:`Creating/dropping schemas <schemas_page>`
40+
* :ref:`Case insensitive index <case_insensitive_unique_index_page>`
4441

45-
Support for managing Postgres schemas.
42+
Case insensitive index, allows searching a column and ignoring the casing.
43+
44+
For Django 2.2 and older:
45+
46+
* :ref:`Unique index <unique_index_page>`
47+
48+
Unique indices that can span more than one field.
49+
50+
* :ref:`HStore key unique & required constraint <hstore_page>`
51+
52+
Add unique and required constraints in specific hstore keys.
4653

4754

4855
.. toctree::

docs/source/indexes.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ Indexes
77

88
Unique Index
99
-----------------------------
10+
11+
.. warning::
12+
13+
In Django 2.2 or newer, you might want to use :class:`~django.db.models.UniqueConstraint` instead.
14+
1015
The :class:`~psqlextra.indexes.UniqueIndex` lets you create a unique index. Normally Django only allows you to create unique indexes by specifying ``unique=True`` on the model field.
1116

1217
Although it can be used on any Django model, it is most useful on views and materialized views where ``unique=True`` does not work.
@@ -32,13 +37,14 @@ Although it can be used on any Django model, it is most useful on views and mate
3237

3338
Conditional Unique Index
3439
------------------------
35-
The :class:`~psqlextra.indexes.ConditionalUniqueIndex` lets you create partial unique indexes in case you ever need :attr:`~django:django.db.models.Options.unique_together` constraints
36-
on nullable columns.
3740

3841
.. warning::
3942

4043
In Django 3.1 or newer, you might want to use :attr:`~django.db.models.indexes.condition` instead.
4144

45+
The :class:`~psqlextra.indexes.ConditionalUniqueIndex` lets you create partial unique indexes in case you ever need :attr:`~django:django.db.models.Options.unique_together` constraints
46+
on nullable columns.
47+
4248
Before:
4349

4450
.. code-block:: python
@@ -83,6 +89,11 @@ After:
8389

8490
Case Insensitive Unique Index
8591
-----------------------------
92+
93+
.. warning::
94+
95+
In Django 3.1 or newer, you might want to use :attr:`~django.db.models.indexes.condition` instead.
96+
8697
The :class:`~psqlextra.indexes.CaseInsensitiveUniqueIndex` lets you create an index that ignores the casing for the specified field(s).
8798

8899
This makes the field(s) behave more like a text field in MySQL.

0 commit comments

Comments
 (0)