From 241eb8e0aeeb519853ddfb69685b01b35a17fc51 Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Fri, 22 Oct 2021 00:41:12 +0530 Subject: [PATCH 1/5] chore: release 2.2.1b4 Release-As: 2.2.1b4 From 53ee24c297bab00792d921520da98177c37abf44 Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Mon, 28 Feb 2022 12:18:02 +0530 Subject: [PATCH 2/5] docs: Add spanner django limitations from spanner perspective --- README.rst | 5 +- docs/limitations-spanner.rst | 96 ++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 docs/limitations-spanner.rst diff --git a/README.rst b/README.rst index 2fa6790064..c4d7096328 100644 --- a/README.rst +++ b/README.rst @@ -246,4 +246,7 @@ Spanner has certain limitations of its own. The full set of limitations is docum It is recommended that you go through that list. Django spanner has a set of limitations as well, which you can find -`here `__. \ No newline at end of file +`here `__. + +Features from spanner that are not supported in Django-spanner are listed +`here `__. diff --git a/docs/limitations-spanner.rst b/docs/limitations-spanner.rst new file mode 100644 index 0000000000..a58f2eef1e --- /dev/null +++ b/docs/limitations-spanner.rst @@ -0,0 +1,96 @@ +Limitations from Spanner perspective +------------------------------------ + +Below is a List of Limitations for features that are supported in Spanner but +are not supported in the Django Spanner library. Some features have been +disabled because of compatibility issues using the Django feature toggle. + +Query Hints +~~~~~~~~~~~ +Django automatically manages query generation and thus does not expose methods +to add query hints directly. While libraries can add support for this feature +and manage the query generation part, we have not added this because of the +added complexity. The workaround to use this feature is by using Raw Queries +directly, and adding Query hints there. + +Mutations +~~~~~~~~~ +Mutations are not a concept that is understood by Django so it does not support +it inherently. The workaround is to use python-spanner objects and run Mutations using that. + +Batch DDL +~~~~~~~~~ +Migrations (creation and updation) of tables in Django are sequential operations. +Django doesn't inherently support doing batch DDL operations. However, customers +can use python-spanner objects to run batch DDL for unmanaged tables in Django. + +Stale Reads +~~~~~~~~~~~ +Stale Reads are not a concept that is understood by Django so it does not support +it inherently. The workaround is to use python-spanner objects and run read operations on snapshots. + +Interleaving +~~~~~~~~~~~~ +Interleaving is not a concept that is understood by Django so it does not support +it inherently. The workaround is to use Unmanaged tables and python-spanner objects +to create and manage interleaved tables. + + +Partitioned DML +~~~~~~~~~~~~~~~ +Partitioned DML is not a concept that is understood by Django so it does not support +it inherently. The workaround is to use python-spanner objects to perform partitioned +DML operations. + +Session Labeling +~~~~~~~~~~~~~~~~ +Django does not support session pools for databases directly and does not have the +concept of session labeling itself. The workaround is to use python-spanner objects +to create and manage sessions along with Session labels. + +Request Priority +~~~~~~~~~~~~~~~~ +Request Priority for database calls is not a concept that is understood by Django so +it does not support it inherently. The workaround is to use python-spanner objects +and use request priority as part of the db calls. + +Tagging +~~~~~~~ +Tagging for database calls is not a concept that is understood by Django so it does not +support it inherently. The workaround is to use python-spanner objects and use the +tagging feature via that. + +Configurable Leader Option +~~~~~~~~~~~~~~~~~~~~~~~~~~ +Configuring Leader Option for database calls is not a concept that is understood by +Django so it does not support it inherently. The workaround is to use python-spanner +objects while creating the database. + +Backups / Cross region Backups +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Backups for databases are not managed by Django so it does not support it inherently. +In general, none of the Spanner ORMs / drivers are expected to support backup management. +The workaround is to use python-spanner objects and use backup features via that. + +Custom Instance Config +~~~~~~~~~~~~~~~~~~~~~~ +Instances for spanner are not managed by Django so it does not support it inherently. +The workaround is to use python-spanner objects and use Instance config features via that. + +Workaround +========== + +| Features | Is a workaround available? | +| --- | --- | +| Query Hints | Raw Queries can be used for Query hints [Link] (https://stackoverflow.com/a/28350704/3027854) | +| Mutations | Python-spanner database objects can be used to run Mutation queries. [Link] (https://cloud.google.com/spanner/docs/modify-mutation-api#python) | +| Batch DDL | Using unmanaged tables in Django. [Link] (https://docs.djangoproject.com/en/4.0/ref/models/options/#managed) and Directly using Python spanner objects to execute batch DDL statements. [Link] (https://cloud.google.com/spanner/docs/getting-started/python#create_a_database) | +| Stale Reads | Python-spanner database objects can be used to perform stale reads. [Link] (https://cloud.google.com/spanner/docs/reads#python) | +| Interleaving | Using unmanaged tables in Django. [Link] (https://docs.djangoproject.com/en/4.0/ref/models/options/#managed) and Directly using Python spanner objects to create interleaved tables. [Link] (https://cloud.google.com/spanner/docs/getting-started/python#create_a_database) | +| Partitioned DML | Python-spanner database objects can be used to perform Partitioned DML. [Link] (https://cloud.google.com/spanner/docs/dml-partitioned#python) | +| Session Labeling | Python-spanner connection objects can be used to perform Session creation and labeling . [Link] (https://cloud.google.com/spanner/docs/sessions#python) | +| Request Priority | Python-spanner connection objects can be used to make backend calls with request priority. [Link] (https://cloud.google.com/spanner/docs/reference/rest/v1/RequestOptions) | +| Tagging | Python-spanner connection objects can be used to make backend calls with request tags. [Link] (https://cloud.google.com/spanner/docs/reference/rest/v1/RequestOptions) | +| Configurable Leader Option | Python-spanner database objects can be used to set or update leader options. [Link] (https://cloud.google.com/spanner/docs/modifying-leader-region#python) | +| Cross region backup | Python-spanner library can be used to perform db backups across regions. [Link] (https://cloud.google.com/spanner/docs/backup) | +| Custom Instance Config | Python-spanner library can be used to manage instances. [Link] (https://googleapis.dev/python/spanner/latest/instance-api.html) | From 831edacefae72be668647a422eade4e307af74ec Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Mon, 28 Feb 2022 12:29:43 +0530 Subject: [PATCH 3/5] docs: refactored table layout for workarounds in spanner limitations files --- docs/limitations-spanner.rst | 48 ++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/docs/limitations-spanner.rst b/docs/limitations-spanner.rst index a58f2eef1e..5d3671effe 100644 --- a/docs/limitations-spanner.rst +++ b/docs/limitations-spanner.rst @@ -78,19 +78,35 @@ Instances for spanner are not managed by Django so it does not support it inhere The workaround is to use python-spanner objects and use Instance config features via that. Workaround -========== - -| Features | Is a workaround available? | -| --- | --- | -| Query Hints | Raw Queries can be used for Query hints [Link] (https://stackoverflow.com/a/28350704/3027854) | -| Mutations | Python-spanner database objects can be used to run Mutation queries. [Link] (https://cloud.google.com/spanner/docs/modify-mutation-api#python) | -| Batch DDL | Using unmanaged tables in Django. [Link] (https://docs.djangoproject.com/en/4.0/ref/models/options/#managed) and Directly using Python spanner objects to execute batch DDL statements. [Link] (https://cloud.google.com/spanner/docs/getting-started/python#create_a_database) | -| Stale Reads | Python-spanner database objects can be used to perform stale reads. [Link] (https://cloud.google.com/spanner/docs/reads#python) | -| Interleaving | Using unmanaged tables in Django. [Link] (https://docs.djangoproject.com/en/4.0/ref/models/options/#managed) and Directly using Python spanner objects to create interleaved tables. [Link] (https://cloud.google.com/spanner/docs/getting-started/python#create_a_database) | -| Partitioned DML | Python-spanner database objects can be used to perform Partitioned DML. [Link] (https://cloud.google.com/spanner/docs/dml-partitioned#python) | -| Session Labeling | Python-spanner connection objects can be used to perform Session creation and labeling . [Link] (https://cloud.google.com/spanner/docs/sessions#python) | -| Request Priority | Python-spanner connection objects can be used to make backend calls with request priority. [Link] (https://cloud.google.com/spanner/docs/reference/rest/v1/RequestOptions) | -| Tagging | Python-spanner connection objects can be used to make backend calls with request tags. [Link] (https://cloud.google.com/spanner/docs/reference/rest/v1/RequestOptions) | -| Configurable Leader Option | Python-spanner database objects can be used to set or update leader options. [Link] (https://cloud.google.com/spanner/docs/modifying-leader-region#python) | -| Cross region backup | Python-spanner library can be used to perform db backups across regions. [Link] (https://cloud.google.com/spanner/docs/backup) | -| Custom Instance Config | Python-spanner library can be used to manage instances. [Link] (https://googleapis.dev/python/spanner/latest/instance-api.html) | +---------- + +.. list-table:: Workaround + :widths: 33 67 + :header-rows: 1 + + * - Features + - Is a workaround available? + * - Query Hints + - Raw Queries can be used for Query hints `Link `__. + * - Mutations + - Python-spanner database objects can be used to run Mutation queries. `Link `__. + * - Batch DDL + - Using unmanaged tables in Django. `Link `__ and Directly using Python spanner objects to execute batch DDL statements. `Link `__. + * - Stale Reads + - Python-spanner database objects can be used to perform stale reads. `Link `__. + * - Interleaving + - Using unmanaged tables in Django. `Link `__ and Directly using Python spanner objects to create interleaved tables. `Link `__. + * - Partitioned DML + - Python-spanner database objects can be used to perform Partitioned DML. `Link `__. + * - Session Labeling + - Python-spanner connection objects can be used to perform Session creation and labeling . `Link `__. + * - Request Priority + - Python-spanner connection objects can be used to make backend calls with request priority. `Link `__. + * - Tagging + - Python-spanner connection objects can be used to make backend calls with request tags. `Link `__. + * - Configurable Leader Option + - Python-spanner database objects can be used to set or update leader options. `Link `__. + * - Cross region backup + - Python-spanner library can be used to perform db backups across regions. `Link `__. + * - Custom Instance Config + - Python-spanner library can be used to manage instances. `Link `__. From de96767a7ce8334c1df49bb3d687fc366c3df2fc Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Mon, 28 Feb 2022 12:31:20 +0530 Subject: [PATCH 4/5] refactor: remove double occurance of work workaround in spanner limitations file --- docs/limitations-spanner.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/limitations-spanner.rst b/docs/limitations-spanner.rst index 5d3671effe..75cbbebaf6 100644 --- a/docs/limitations-spanner.rst +++ b/docs/limitations-spanner.rst @@ -80,7 +80,7 @@ The workaround is to use python-spanner objects and use Instance config features Workaround ---------- -.. list-table:: Workaround +.. list-table:: :widths: 33 67 :header-rows: 1 From bd6129cbc63ac2c515141e4b16ac31792094364c Mon Sep 17 00:00:00 2001 From: Vikash Singh <3116482+vi3k6i5@users.noreply.github.com> Date: Tue, 12 Apr 2022 14:27:33 +0530 Subject: [PATCH 5/5] feat: enabled transaction support --- django_spanner/features.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_spanner/features.py b/django_spanner/features.py index d2099a78f0..7ab8e3b0c1 100644 --- a/django_spanner/features.py +++ b/django_spanner/features.py @@ -31,7 +31,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): supports_select_for_update_with_limit = False supports_sequence_reset = False supports_timezones = False - supports_transactions = False + supports_transactions = True if USE_EMULATOR: # Emulator does not support json. supports_json_field = False