From 484504a8426c5d16c6937f4b26074588e84b85ee Mon Sep 17 00:00:00 2001 From: "STATION\\mf" Date: Fri, 11 Sep 2020 17:19:39 -0400 Subject: [PATCH 1/4] chore: `spanner_dbapi` moved into `google/cloud/` --- django_spanner/base.py | 3 +-- django_spanner/operations.py | 2 +- google/__init__.py | 0 google/cloud/__init__.py | 0 {spanner_dbapi => google/cloud/spanner_dbapi}/__init__.py | 0 {spanner_dbapi => google/cloud/spanner_dbapi}/connection.py | 0 {spanner_dbapi => google/cloud/spanner_dbapi}/cursor.py | 0 {spanner_dbapi => google/cloud/spanner_dbapi}/exceptions.py | 0 .../cloud/spanner_dbapi}/parse_utils.py | 0 {spanner_dbapi => google/cloud/spanner_dbapi}/parser.py | 0 {spanner_dbapi => google/cloud/spanner_dbapi}/types.py | 0 {spanner_dbapi => google/cloud/spanner_dbapi}/utils.py | 0 {spanner_dbapi => google/cloud/spanner_dbapi}/version.py | 0 tests/spanner_dbapi/test_connect.py | 2 +- tests/spanner_dbapi/test_connection.py | 2 +- tests/spanner_dbapi/test_cursor.py | 2 +- tests/spanner_dbapi/test_parse_utils.py | 6 +++--- tests/spanner_dbapi/test_parser.py | 4 ++-- tests/spanner_dbapi/test_types.py | 4 ++-- tests/spanner_dbapi/test_utils.py | 2 +- tests/spanner_dbapi/test_version.py | 2 +- 21 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 google/__init__.py create mode 100644 google/cloud/__init__.py rename {spanner_dbapi => google/cloud/spanner_dbapi}/__init__.py (100%) rename {spanner_dbapi => google/cloud/spanner_dbapi}/connection.py (100%) rename {spanner_dbapi => google/cloud/spanner_dbapi}/cursor.py (100%) rename {spanner_dbapi => google/cloud/spanner_dbapi}/exceptions.py (100%) rename {spanner_dbapi => google/cloud/spanner_dbapi}/parse_utils.py (100%) rename {spanner_dbapi => google/cloud/spanner_dbapi}/parser.py (100%) rename {spanner_dbapi => google/cloud/spanner_dbapi}/types.py (100%) rename {spanner_dbapi => google/cloud/spanner_dbapi}/utils.py (100%) rename {spanner_dbapi => google/cloud/spanner_dbapi}/version.py (100%) diff --git a/django_spanner/base.py b/django_spanner/base.py index c63e7dfe54..a376273514 100644 --- a/django_spanner/base.py +++ b/django_spanner/base.py @@ -4,9 +4,8 @@ # license that can be found in the LICENSE file or at # https://developers.google.com/open-source/licenses/bsd -import spanner_dbapi as Database from django.db.backends.base.base import BaseDatabaseWrapper -from google.cloud import spanner_v1 as spanner +from google.cloud import spanner_v1 as spanner, spanner_dbapi as Database from .client import DatabaseClient from .creation import DatabaseCreation diff --git a/django_spanner/operations.py b/django_spanner/operations.py index 8aee6bcc12..db3b5f6a0b 100644 --- a/django_spanner/operations.py +++ b/django_spanner/operations.py @@ -16,7 +16,7 @@ from django.db.utils import DatabaseError from django.utils import timezone from django.utils.duration import duration_microseconds -from spanner_dbapi.parse_utils import DateStr, TimestampStr, escape_name +from google.cloud.spanner_dbapi import DateStr, TimestampStr, escape_name class DatabaseOperations(BaseDatabaseOperations): diff --git a/google/__init__.py b/google/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/google/cloud/__init__.py b/google/cloud/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spanner_dbapi/__init__.py b/google/cloud/spanner_dbapi/__init__.py similarity index 100% rename from spanner_dbapi/__init__.py rename to google/cloud/spanner_dbapi/__init__.py diff --git a/spanner_dbapi/connection.py b/google/cloud/spanner_dbapi/connection.py similarity index 100% rename from spanner_dbapi/connection.py rename to google/cloud/spanner_dbapi/connection.py diff --git a/spanner_dbapi/cursor.py b/google/cloud/spanner_dbapi/cursor.py similarity index 100% rename from spanner_dbapi/cursor.py rename to google/cloud/spanner_dbapi/cursor.py diff --git a/spanner_dbapi/exceptions.py b/google/cloud/spanner_dbapi/exceptions.py similarity index 100% rename from spanner_dbapi/exceptions.py rename to google/cloud/spanner_dbapi/exceptions.py diff --git a/spanner_dbapi/parse_utils.py b/google/cloud/spanner_dbapi/parse_utils.py similarity index 100% rename from spanner_dbapi/parse_utils.py rename to google/cloud/spanner_dbapi/parse_utils.py diff --git a/spanner_dbapi/parser.py b/google/cloud/spanner_dbapi/parser.py similarity index 100% rename from spanner_dbapi/parser.py rename to google/cloud/spanner_dbapi/parser.py diff --git a/spanner_dbapi/types.py b/google/cloud/spanner_dbapi/types.py similarity index 100% rename from spanner_dbapi/types.py rename to google/cloud/spanner_dbapi/types.py diff --git a/spanner_dbapi/utils.py b/google/cloud/spanner_dbapi/utils.py similarity index 100% rename from spanner_dbapi/utils.py rename to google/cloud/spanner_dbapi/utils.py diff --git a/spanner_dbapi/version.py b/google/cloud/spanner_dbapi/version.py similarity index 100% rename from spanner_dbapi/version.py rename to google/cloud/spanner_dbapi/version.py diff --git a/tests/spanner_dbapi/test_connect.py b/tests/spanner_dbapi/test_connect.py index 716df619fb..fc1a62550a 100644 --- a/tests/spanner_dbapi/test_connect.py +++ b/tests/spanner_dbapi/test_connect.py @@ -11,7 +11,7 @@ import google.auth.credentials from google.api_core.gapic_v1.client_info import ClientInfo -from spanner_dbapi import connect, Connection +from google.cloud.spanner_dbapi import connect, Connection def _make_credentials(): diff --git a/tests/spanner_dbapi/test_connection.py b/tests/spanner_dbapi/test_connection.py index ab72f799df..e7cd3f361f 100644 --- a/tests/spanner_dbapi/test_connection.py +++ b/tests/spanner_dbapi/test_connection.py @@ -9,7 +9,7 @@ import unittest from unittest import mock -from spanner_dbapi import connect, InterfaceError +from google.cloud.spanner_dbapi import connect, InterfaceError class TestConnection(unittest.TestCase): diff --git a/tests/spanner_dbapi/test_cursor.py b/tests/spanner_dbapi/test_cursor.py index 6bf6bb27e4..722bbbcb8a 100644 --- a/tests/spanner_dbapi/test_cursor.py +++ b/tests/spanner_dbapi/test_cursor.py @@ -9,7 +9,7 @@ import unittest from unittest import mock -from spanner_dbapi import connect, InterfaceError +from google.cloud.spanner_dbapi import connect, InterfaceError class TestCursor(unittest.TestCase): diff --git a/tests/spanner_dbapi/test_parse_utils.py b/tests/spanner_dbapi/test_parse_utils.py index 91d795ad0f..0f2fb612a6 100644 --- a/tests/spanner_dbapi/test_parse_utils.py +++ b/tests/spanner_dbapi/test_parse_utils.py @@ -9,8 +9,8 @@ from unittest import TestCase from google.cloud.spanner_v1 import param_types -from spanner_dbapi.exceptions import Error, ProgrammingError -from spanner_dbapi.parse_utils import ( +from google.cloud.spanner_dbapi.exceptions import Error, ProgrammingError +from google.cloud.spanner_dbapi.parse_utils import ( STMT_DDL, STMT_NON_UPDATING, DateStr, @@ -24,7 +24,7 @@ sql_pyformat_args_to_spanner, strip_backticks, ) -from spanner_dbapi.utils import backtick_unicode +from google.cloud.spanner_dbapi.utils import backtick_unicode class ParseUtilsTests(TestCase): diff --git a/tests/spanner_dbapi/test_parser.py b/tests/spanner_dbapi/test_parser.py index 8e08775a86..b8a2c49ddf 100644 --- a/tests/spanner_dbapi/test_parser.py +++ b/tests/spanner_dbapi/test_parser.py @@ -6,8 +6,8 @@ from unittest import TestCase -from spanner_dbapi.exceptions import ProgrammingError -from spanner_dbapi.parser import ( +from google.cloud.spanner_dbapi.exceptions import ProgrammingError +from google.cloud.spanner_dbapi.parser import ( ARGS, FUNC, TERMINAL, diff --git a/tests/spanner_dbapi/test_types.py b/tests/spanner_dbapi/test_types.py index 690ec7463f..642f43f340 100644 --- a/tests/spanner_dbapi/test_types.py +++ b/tests/spanner_dbapi/test_types.py @@ -7,7 +7,7 @@ import datetime from unittest import TestCase -from spanner_dbapi.types import ( +from google.cloud.spanner_dbapi.types import ( Date, DateFromTicks, Time, @@ -15,7 +15,7 @@ Timestamp, TimestampFromTicks, ) -from spanner_dbapi.utils import PeekIterator +from google.cloud.spanner_dbapi.utils import PeekIterator tzUTC = 0 # 0 hours offset from UTC diff --git a/tests/spanner_dbapi/test_utils.py b/tests/spanner_dbapi/test_utils.py index 8ffcd99d2f..36f6083ae9 100644 --- a/tests/spanner_dbapi/test_utils.py +++ b/tests/spanner_dbapi/test_utils.py @@ -6,7 +6,7 @@ from unittest import TestCase -from spanner_dbapi.utils import PeekIterator +from google.cloud.spanner_dbapi.utils import PeekIterator class UtilsTests(TestCase): diff --git a/tests/spanner_dbapi/test_version.py b/tests/spanner_dbapi/test_version.py index ea2c718a2d..c03a8d0438 100644 --- a/tests/spanner_dbapi/test_version.py +++ b/tests/spanner_dbapi/test_version.py @@ -8,7 +8,7 @@ from unittest import TestCase from google.api_core.gapic_v1.client_info import ClientInfo -from spanner_dbapi.version import DEFAULT_USER_AGENT, google_client_info +from google.cloud.spanner_dbapi.version import DEFAULT_USER_AGENT, google_client_info vers = sys.version_info From 603c9b09f79fd260dc7844faffcb331e41b42333 Mon Sep 17 00:00:00 2001 From: "STATION\\mf" Date: Fri, 11 Sep 2020 18:05:52 -0400 Subject: [PATCH 2/4] fix: references to `spanner_dbapi` --- README.rst | 6 +++--- docs/connection-usage.rst | 4 ++-- noxfile.py | 6 +++--- tests/spanner_dbapi/test_connect.py | 7 +++++-- tests/spanner_dbapi/test_globals.py | 2 +- tests/spanner_dbapi/test_version.py | 5 ++++- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index c50e5a79a0..1e911133d1 100644 --- a/README.rst +++ b/README.rst @@ -60,7 +60,7 @@ Django ``settings.py`` file: .. code:: python INSTALLED_APPS = [ - 'spanner_django', + 'django_spanner', ... ] @@ -73,7 +73,7 @@ Format DATABASES = { 'default': { - 'ENGINE': 'spanner_django', + 'ENGINE': 'django_spanner', 'PROJECT': '', 'INSTANCE': '', 'NAME': '', @@ -94,7 +94,7 @@ For example: DATABASES = { 'default': { - 'ENGINE': 'spanner_django', + 'ENGINE': 'django_spanner', 'PROJECT': 'appdev-soda-spanner-staging', # Or the GCP project-id 'INSTANCE': 'django-dev1', # Or the Cloud Spanner instance 'NAME': 'db1', # Or the Cloud Spanner database to use diff --git a/docs/connection-usage.rst b/docs/connection-usage.rst index 9049e3e2b2..eb4fea228d 100644 --- a/docs/connection-usage.rst +++ b/docs/connection-usage.rst @@ -7,7 +7,7 @@ DB API Connection Creating a Connection --------------------- -To use the API, the :class:`~google.cloud.spanner_django.connection.Connection` +To use the API, the :class:`~google.cloud.django_spanner.connection.Connection` class defines a high-level interface which handles connection to a Spanner databse: @@ -29,4 +29,4 @@ Configuration Engine or Google Compute Engine the project will be detected automatically. (Setting this environment variable is not required, you may instead pass the ``project`` explicitly when constructing a - :class:`~google.cloud.spanner_django.connection.Connection`). + :class:`~google.cloud.django_spanner.connection.Connection`). diff --git a/noxfile.py b/noxfile.py index 016fe33c39..552ce47562 100644 --- a/noxfile.py +++ b/noxfile.py @@ -18,7 +18,7 @@ BLACK_PATHS = [ "django_spanner", "docs", - "spanner_dbapi", + "google", "tests", "noxfile.py", "setup.py", @@ -34,7 +34,7 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run("black", "--check", *BLACK_PATHS) - session.run("flake8", "django_spanner", "spanner_dbapi", "tests") + session.run("flake8", "django_spanner", "google", "tests") @nox.session(python="3.8") @@ -70,7 +70,7 @@ def default(session): "py.test", "--quiet", "--cov=django_spanner", - "--cov=spanner_dbapi", + "--cov=google.cloud", "--cov=tests.spanner_dbapi", "--cov-append", "--cov-config=.coveragerc", diff --git a/tests/spanner_dbapi/test_connect.py b/tests/spanner_dbapi/test_connect.py index fc1a62550a..260d3a0993 100644 --- a/tests/spanner_dbapi/test_connect.py +++ b/tests/spanner_dbapi/test_connect.py @@ -30,9 +30,12 @@ def test_connect(self): CREDENTIALS = _make_credentials() CLIENT_INFO = ClientInfo(user_agent=USER_AGENT) - with mock.patch("spanner_dbapi.spanner_v1.Client") as client_mock: + with mock.patch( + "google.cloud.spanner_dbapi.spanner_v1.Client" + ) as client_mock: with mock.patch( - "spanner_dbapi.google_client_info", return_value=CLIENT_INFO + "google.cloud.spanner_dbapi.google_client_info", + return_value=CLIENT_INFO, ) as client_info_mock: connection = connect( diff --git a/tests/spanner_dbapi/test_globals.py b/tests/spanner_dbapi/test_globals.py index 729aa89978..7c3e0396a9 100644 --- a/tests/spanner_dbapi/test_globals.py +++ b/tests/spanner_dbapi/test_globals.py @@ -6,7 +6,7 @@ from unittest import TestCase -from spanner_dbapi import apilevel, paramstyle, threadsafety +from google.cloud.spanner_dbapi import apilevel, paramstyle, threadsafety class DBAPIGlobalsTests(TestCase): diff --git a/tests/spanner_dbapi/test_version.py b/tests/spanner_dbapi/test_version.py index c03a8d0438..9dfed1f55f 100644 --- a/tests/spanner_dbapi/test_version.py +++ b/tests/spanner_dbapi/test_version.py @@ -8,7 +8,10 @@ from unittest import TestCase from google.api_core.gapic_v1.client_info import ClientInfo -from google.cloud.spanner_dbapi.version import DEFAULT_USER_AGENT, google_client_info +from google.cloud.spanner_dbapi.version import ( + DEFAULT_USER_AGENT, + google_client_info, +) vers = sys.version_info From eee9b037c0b0504e53afc481f7dfb14444c13c75 Mon Sep 17 00:00:00 2001 From: "STATION\\mf" Date: Fri, 11 Sep 2020 18:38:36 -0400 Subject: [PATCH 3/4] fix: updated distribution names --- README.rst | 26 +++++++------- .../__init__.py | 0 .../base.py | 2 +- .../client.py | 0 .../compiler.py | 0 .../creation.py | 0 .../expressions.py | 0 .../features.py | 8 ++--- .../functions.py | 0 .../introspection.py | 0 .../lookups.py | 0 .../operations.py | 2 +- .../schema.py | 0 .../utils.py | 8 ++--- .../validation.py | 0 django_test_suite.sh | 4 +-- docs/conf.py | 4 +-- docs/connection-usage.rst | 4 +-- docs/index.rst | 2 +- examples/from-scratch/README.md | 26 +++++++------- examples/healthchecks/README.md | 34 +++++++++---------- google/cloud/spanner_dbapi/version.py | 2 +- noxfile.py | 6 ++-- 23 files changed, 64 insertions(+), 64 deletions(-) rename {django_spanner => django_google_spanner}/__init__.py (100%) rename {django_spanner => django_google_spanner}/base.py (98%) rename {django_spanner => django_google_spanner}/client.py (100%) rename {django_spanner => django_google_spanner}/compiler.py (100%) rename {django_spanner => django_google_spanner}/creation.py (100%) rename {django_spanner => django_google_spanner}/expressions.py (100%) rename {django_spanner => django_google_spanner}/features.py (99%) rename {django_spanner => django_google_spanner}/functions.py (100%) rename {django_spanner => django_google_spanner}/introspection.py (100%) rename {django_spanner => django_google_spanner}/lookups.py (100%) rename {django_spanner => django_google_spanner}/operations.py (99%) rename {django_spanner => django_google_spanner}/schema.py (100%) rename {django_spanner => django_google_spanner}/utils.py (56%) rename {django_spanner => django_google_spanner}/validation.py (100%) diff --git a/README.rst b/README.rst index 1e911133d1..073d5bcca9 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ -django-spanner -============== +django-google-spanner +===================== ORM plugin for using Cloud Spanner as a database for Django. @@ -37,12 +37,12 @@ Table of contents Installing it ------------- -Use the version of django-spanner that corresponds to your version of -Django. For example, django-spanner 2.2.x works with Django 2.2.y. (This +Use the version of django-google-spanner that corresponds to your version of +Django. For example, django-google-spanner 2.2.x works with Django 2.2.y. (This is the only supported version at this time.) The minor release number of Django doesn't correspond to the minor -release number of django-spanner. Use the latest minor release of each. +release number of django-google-spanner. Use the latest minor release of each. .. code:: shell @@ -54,13 +54,13 @@ Using it After `installing it <#installing-it>`__, you'll need to edit your Django ``settings.py`` file: -- Add ``django_spanner`` as the very first entry in the +- Add ``django_google_spanner`` as the very first entry in the ``INSTALLED_APPS`` setting .. code:: python INSTALLED_APPS = [ - 'django_spanner', + 'django_google_spanner', ... ] @@ -73,7 +73,7 @@ Format DATABASES = { 'default': { - 'ENGINE': 'django_spanner', + 'ENGINE': 'django_google_spanner', 'PROJECT': '', 'INSTANCE': '', 'NAME': '', @@ -94,7 +94,7 @@ For example: DATABASES = { 'default': { - 'ENGINE': 'django_spanner', + 'ENGINE': 'django_google_spanner', 'PROJECT': 'appdev-soda-spanner-staging', # Or the GCP project-id 'INSTANCE': 'django-dev1', # Or the Cloud Spanner instance 'NAME': 'db1', # Or the Cloud Spanner database to use @@ -107,7 +107,7 @@ Limitations Transaction management isn't supported ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -django-spanner always works in Django's default transaction behavior, +django-google-spanner always works in Django's default transaction behavior, ``autocommit`` mode. Transactions cannot be controlled manually with calls like ``django.db.transaction.atomic()``. @@ -115,7 +115,7 @@ calls like ``django.db.transaction.atomic()``. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Spanner doesn't have support for auto-generating primary key values. -Therefore, django-spanner monkey-patches ``AutoField`` to generate a +Therefore, django-google-spanner monkey-patches ``AutoField`` to generate a random UUID4. It generates a default using ``Field``'s ``default`` option which means ``AutoField``\ s will have a value when a model instance is created. For example: @@ -136,7 +136,7 @@ were created. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Spanner doesn't support ``ON DELETE CASCADE`` when creating foreign-key -constraints so django-spanner `doesn't support foreign key +constraints so django-google-spanner `doesn't support foreign key constraints `__. Check constraints aren't supported @@ -185,7 +185,7 @@ Spanner has some limitations on schema changes which you must respect: - Renaming tables and columns isn't supported. - A column's type can't be changed. - A table's primary key can't be altered. -- Migrations aren't atomic since django-spanner doesn't support +- Migrations aren't atomic since django-google-spanner doesn't support transactions. ``DurationField`` arithmetic doesn't work with ``DateField`` values (`#253 `__) diff --git a/django_spanner/__init__.py b/django_google_spanner/__init__.py similarity index 100% rename from django_spanner/__init__.py rename to django_google_spanner/__init__.py diff --git a/django_spanner/base.py b/django_google_spanner/base.py similarity index 98% rename from django_spanner/base.py rename to django_google_spanner/base.py index a376273514..245f12da07 100644 --- a/django_spanner/base.py +++ b/django_google_spanner/base.py @@ -116,7 +116,7 @@ def get_connection_params(self): "project": self.settings_dict["PROJECT"], "instance_id": self.settings_dict["INSTANCE"], "database_id": self.settings_dict["NAME"], - "user_agent": "django_spanner/0.0.1", + "user_agent": "django_google_spanner/0.0.1", **self.settings_dict["OPTIONS"], } diff --git a/django_spanner/client.py b/django_google_spanner/client.py similarity index 100% rename from django_spanner/client.py rename to django_google_spanner/client.py diff --git a/django_spanner/compiler.py b/django_google_spanner/compiler.py similarity index 100% rename from django_spanner/compiler.py rename to django_google_spanner/compiler.py diff --git a/django_spanner/creation.py b/django_google_spanner/creation.py similarity index 100% rename from django_spanner/creation.py rename to django_google_spanner/creation.py diff --git a/django_spanner/expressions.py b/django_google_spanner/expressions.py similarity index 100% rename from django_spanner/expressions.py rename to django_google_spanner/expressions.py diff --git a/django_spanner/features.py b/django_google_spanner/features.py similarity index 99% rename from django_spanner/features.py rename to django_google_spanner/features.py index ab53836e60..4a93d56627 100644 --- a/django_spanner/features.py +++ b/django_google_spanner/features.py @@ -41,7 +41,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): "fixtures_regress.tests.TestFixtures.test_loaddata_raises_error_when_fixture_has_invalid_foreign_key", # No Django transaction management in Spanner. "basic.tests.SelectOnSaveTests.test_select_on_save_lying_update", - # django_spanner monkey patches AutoField to have a default value. + # django_google_spanner monkey patches AutoField to have a default value. "basic.tests.ModelTest.test_hash", "generic_relations.test_forms.GenericInlineFormsetTests.test_options", "generic_relations.tests.GenericRelationsTests.test_unsaved_instance_on_generic_foreign_key", @@ -218,7 +218,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): "admin_views.test_multidb.MultiDatabaseTests.test_delete_view", "auth_tests.test_admin_multidb.MultiDatabaseTests.test_add_view", "contenttypes_tests.test_models.ContentTypesMultidbTests.test_multidb", - # Tests that by-pass using django_spanner and generate + # Tests that by-pass using django_google_spanner and generate # invalid DDL: https://github.com/orijtech/django-spanner/issues/298 "cache.tests.CreateCacheTableForDBCacheTests", "cache.tests.DBCacheTests", @@ -317,10 +317,10 @@ class DatabaseFeatures(BaseDatabaseFeatures): # This test isn't isolated on databases like Spanner that don't # support transactions: https://code.djangoproject.com/ticket/31413 "migrations.test_loader.LoaderTests.test_loading_squashed", - # Probably due to django-spanner setting a default on AutoField: + # Probably due to django-google-spanner setting a default on AutoField: # https://github.com/googleapis/python-spanner-django/issues/422 "model_inheritance_regress.tests.ModelInheritanceTest.test_issue_6755", - # Probably due to django-spanner setting a default on AutoField: + # Probably due to django-google-spanner setting a default on AutoField: # https://github.com/googleapis/python-spanner-django/issues/424 "model_formsets.tests.ModelFormsetTest.test_prevent_change_outer_model_and_create_invalid_data", "model_formsets_regress.tests.FormfieldShouldDeleteFormTests.test_no_delete", diff --git a/django_spanner/functions.py b/django_google_spanner/functions.py similarity index 100% rename from django_spanner/functions.py rename to django_google_spanner/functions.py diff --git a/django_spanner/introspection.py b/django_google_spanner/introspection.py similarity index 100% rename from django_spanner/introspection.py rename to django_google_spanner/introspection.py diff --git a/django_spanner/lookups.py b/django_google_spanner/lookups.py similarity index 100% rename from django_spanner/lookups.py rename to django_google_spanner/lookups.py diff --git a/django_spanner/operations.py b/django_google_spanner/operations.py similarity index 99% rename from django_spanner/operations.py rename to django_google_spanner/operations.py index db3b5f6a0b..7a8d6876cb 100644 --- a/django_spanner/operations.py +++ b/django_google_spanner/operations.py @@ -22,7 +22,7 @@ class DatabaseOperations(BaseDatabaseOperations): cast_data_types = {"CharField": "STRING", "TextField": "STRING"} cast_char_field_without_max_length = "STRING" - compiler_module = "django_spanner.compiler" + compiler_module = "django_google_spanner.compiler" # Django's lookup names that require a different name in Spanner's # EXTRACT() function. # https://cloud.google.com/spanner/docs/functions-and-operators#extract diff --git a/django_spanner/schema.py b/django_google_spanner/schema.py similarity index 100% rename from django_spanner/schema.py rename to django_google_spanner/schema.py diff --git a/django_spanner/utils.py b/django_google_spanner/utils.py similarity index 56% rename from django_spanner/utils.py rename to django_google_spanner/utils.py index 1136c33a87..f8a5d08620 100644 --- a/django_spanner/utils.py +++ b/django_google_spanner/utils.py @@ -5,16 +5,16 @@ def check_django_compatability(): """ - Verify that this version of django-spanner is compatible with the installed - version of Django. For example, any django-spanner 2.2.x is compatible + Verify that this version of django-google-spanner is compatible with the installed + version of Django. For example, any django-google-spanner 2.2.x is compatible with Django 2.2.y. """ from . import __version__ if django.VERSION[:2] != get_version_tuple(__version__)[:2]: raise ImproperlyConfigured( - "You must use the latest version of django-spanner {A}.{B}.x " - "with Django {A}.{B}.y (found django-spanner {C}).".format( + "You must use the latest version of django-google-spanner {A}.{B}.x " + "with Django {A}.{B}.y (found django-google-spanner {C}).".format( A=django.VERSION[0], B=django.VERSION[1], C=__version__ ) ) diff --git a/django_spanner/validation.py b/django_google_spanner/validation.py similarity index 100% rename from django_spanner/validation.py rename to django_google_spanner/validation.py diff --git a/django_test_suite.sh b/django_test_suite.sh index e87cd6167f..4201b15893 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -23,13 +23,13 @@ create_settings() { cat << ! > "$SETTINGS_FILE.py" DATABASES = { 'default': { - 'ENGINE': 'django_spanner', + 'ENGINE': 'django_google_spanner', 'PROJECT': "$PROJECT", 'INSTANCE': "$INSTANCE", 'NAME': "$TEST_DBNAME", }, 'other': { - 'ENGINE': 'django_spanner', + 'ENGINE': 'django_google_spanner', 'PROJECT': "$PROJECT", 'INSTANCE': "$INSTANCE", 'NAME': "$TEST_DBNAME_OTHER", diff --git a/docs/conf.py b/docs/conf.py index 301495e535..178a844a78 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -70,7 +70,7 @@ master_doc = "index" # General information about the project. -project = u"google-cloud-spanner-django" +project = u"django-google-spanner" copyright = u"2020, Google" author = u"Google APIs" @@ -237,7 +237,7 @@ # html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-spanner-django-doc" +htmlhelp_basename = "django-google-spanner-doc" # -- Options for warnings ------------------------------------------------------ diff --git a/docs/connection-usage.rst b/docs/connection-usage.rst index eb4fea228d..6640ef9259 100644 --- a/docs/connection-usage.rst +++ b/docs/connection-usage.rst @@ -7,7 +7,7 @@ DB API Connection Creating a Connection --------------------- -To use the API, the :class:`~google.cloud.django_spanner.connection.Connection` +To use the API, the :class:`~google.cloud.django_google_spanner.connection.Connection` class defines a high-level interface which handles connection to a Spanner databse: @@ -29,4 +29,4 @@ Configuration Engine or Google Compute Engine the project will be detected automatically. (Setting this environment variable is not required, you may instead pass the ``project`` explicitly when constructing a - :class:`~google.cloud.django_spanner.connection.Connection`). + :class:`~google.cloud.django_google_spanner.connection.Connection`). diff --git a/docs/index.rst b/docs/index.rst index 58fbbf18bc..345ee16f02 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,7 +19,7 @@ API Documentation Changelog --------- -For a list of all ``google-cloud-spanner-django`` releases: +For a list of all ``django-google-spanner`` releases: .. toctree:: :maxdepth: 2 diff --git a/examples/from-scratch/README.md b/examples/from-scratch/README.md index f82a1e4b86..434f34afa4 100644 --- a/examples/from-scratch/README.md +++ b/examples/from-scratch/README.md @@ -1,13 +1,13 @@ -## django-spanner for Django tutorial +## django-google-spanner for Django tutorial -This example shows how to use django-spanner for Cloud Spanner as a backend database for [Django's tutorials](https://docs.djangoproject.com/en/2.2/intro/tutorial01/) +This example shows how to use django-google-spanner for Cloud Spanner as a backend database for [Django's tutorials](https://docs.djangoproject.com/en/2.2/intro/tutorial01/) ### Walkthrough the introduction to Django -### Install django-spanner -We'll need to install `django-spanner`, by cloning this repository and then running `pip3 install` +### Install django-google-spanner +We'll need to install `django-google-spanner`, by cloning this repository and then running `pip3 install` ```shell -git clone https://github.com/googleapis/django-spanner +git clone https://github.com/googleapis/django-google-spanner pip3 install . ``` @@ -20,7 +20,7 @@ or visit this [codelab](https://opencensus.io/codelabs/spanner/#0) ### Follow the tutorial Please follow the guides in https://docs.djangoproject.com/en/2.2/intro/tutorial01/ until the end with a single DISTINCTION: -### Update your settings.py file to use django-spanner +### Update your settings.py file to use django-google-spanner After we have a Cloud Spanner database created, we'll need a few variables: * ProjectID * Instance name @@ -28,10 +28,10 @@ After we have a Cloud Spanner database created, we'll need a few variables: Once in, please edit the file `hc/local_settings.py`, and: -a) add `django_spanner` as the very first entry to your `INSTALLED_APPS` +a) add `django_google_spanner` as the very first entry to your `INSTALLED_APPS` ```python INSTALLED_APPS = [ - 'django_spanner', # Must be listed first. + 'django_google_spanner', # Must be listed first. ... ] ``` @@ -40,7 +40,7 @@ b) update `DATABASES` into the following: ```python DATABASES = { 'default': { - 'ENGINE': 'django_spanner', + 'ENGINE': 'django_google_spanner', 'PROJECT': PROJECT_ID, 'INSTANCE': SPANNER_INSTANCE, 'NAME': SPANNER_DATABASE_NAME, @@ -59,7 +59,7 @@ which when filled out, will look like this ```python DATABASES = { 'default': { - 'ENGINE': 'django_spanner', + 'ENGINE': 'django_google_spanner', 'PROJECT': 'spanner-appdev', 'INSTANCE': 'instance', 'NAME': 'healthchecks_db', @@ -106,7 +106,7 @@ Running migrations: After those migrations are completed, that will be all. Please continue on with the guides. ### Comprehensive hands-on guide -For a more comprehensive, step by step hands-on guide, please visit [using django-spanner from scratch](https://orijtech-161805.firebaseapp.com/quickstart/new_app/) +For a more comprehensive, step by step hands-on guide, please visit [using django-google-spanner from scratch](https://orijtech-161805.firebaseapp.com/quickstart/new_app/) ### References @@ -114,5 +114,5 @@ For a more comprehensive, step by step hands-on guide, please visit [using djang Resource|URL ---|--- Cloud Spanner homepage|https://cloud.google.com/spanner/ -django-spanner project's source code|https://github.com/googleapis/python-spanner-django/ -django-spanner from scratch|https://orijtech-161805.firebaseapp.com/quickstart/new_app/ +django-google-spanner project's source code|https://github.com/googleapis/python-spanner-django/ +django-google-spanner from scratch|https://orijtech-161805.firebaseapp.com/quickstart/new_app/ diff --git a/examples/healthchecks/README.md b/examples/healthchecks/README.md index f28ed4e845..254e362696 100644 --- a/examples/healthchecks/README.md +++ b/examples/healthchecks/README.md @@ -1,11 +1,11 @@ -## django-spanner on healthchecks.io +## django-google-spanner on healthchecks.io -This example shows how to use django-spanner for Cloud Spanner as a backend database for [https://healthchecks.io](https://healthchecks.io) +This example shows how to use django-google-spanner for Cloud Spanner as a backend database for [https://healthchecks.io](https://healthchecks.io) ### Table of contents - [Install healthchecks](#install-healthchecks) -- [Clone django-spanner](#clone-django-spanner) -- [Install django-spanner in the virtual-env](#install-django-spanner-in-the-virtual-env) +- [Clone django-google-spanner](#clone-django-google-spanner) +- [Install django-google-spanner in the virtual-env](#install-django-google-spanner-in-the-virtual-env) - [Ensure you have a Cloud Spanner database already created](#ensure-you-have-a-Cloud-Spanner-database-already-created) - [Update local_settings.py](#update-local_settings.py) - [Run the server](#run-the-server) @@ -18,24 +18,24 @@ This example shows how to use django-spanner for Cloud Spanner as a backend data Please follow the instructions to install [healthchecks.io on Github](https://github.com/healthchecks/healthchecks/). You'll need to active the virtual-env as their install instructions request. -### Clone django-spanner +### Clone django-google-spanner Open a fresh terminal, and go to a location that isn't a parent directory of where you cloned [healthchecks.io](#install-healthchecks). For example we can go to our $HOME/Desktop ```shell cd $HOME/Desktop -git clone https://github.com/googleapis/django-spanner +git clone https://github.com/googleapis/django-google-spanner ``` -Note the full path of where django-spanner has been cloned into, for example +Note the full path of where django-google-spanner has been cloned into, for example ```shell -DJANGO_SPANNER_CODE_DIR=$Desktop/django-spanner +DJANGO_SPANNER_CODE_DIR=$Desktop/django-google-spanner ``` or add it to your environment, perhaps like this ```shell -export DJANGO_SPANNER_CODE_DIR=$Desktop/django-spanner +export DJANGO_SPANNER_CODE_DIR=$Desktop/django-google-spanner ``` -### Install django-spanner in the virtual-env +### Install django-google-spanner in the virtual-env Go back to the directory in which you installed [healthchecks](#install-healthchecks) and ensure your virtual-env is on. Ensure that your environment is reloaded to get the settings for $DJANGO_SPANNER_CODE, or ensure you had manually copied that path. The prompt should look something like this @@ -43,7 +43,7 @@ The prompt should look something like this (hc-venv) $ ``` -now install django-spanner using the path you obtained in [Clone django-spanner](#clone-django-spanner), per +now install django-google-spanner using the path you obtained in [Clone django-google-spanner](#clone-django-google-spanner), per ```shell (h-venv) $ pip3 install $DJANGO_SPANNER_CODE_DIR @@ -62,10 +62,10 @@ After we have a Cloud Spanner database created, we'll need a few variables: * Database name aka DisplayName Once in, please edit the file `hc/local_settings.py` to: -a) Add `django_spanner` as the first entry to `INSTALLED_APPS` +a) Add `django_google_spanner` as the first entry to `INSTALLED_APPS` ```python INSTALLED_APPS = [ - 'django_spanner', # Must be listed first. + 'django_google_spanner', # Must be listed first. ... ] ``` @@ -76,7 +76,7 @@ b) Edit `DATABASES` into the following: ```python DATABASES = { 'default': { - 'ENGINE': 'django_spanner', + 'ENGINE': 'django_google_spanner', 'PROJECT': PROJECT_ID, 'INSTANCE': SPANNER_INSTANCE, 'NAME': SPANNER_DATABASE_NAME, @@ -95,7 +95,7 @@ which when filled out, will look like this ```python DATABASES = { 'default': { - 'ENGINE': 'django_spanner', + 'ENGINE': 'django_google_spanner', 'PROJECT': 'spanner-appdev', 'INSTANCE': 'instance', 'NAME': 'healthchecks_db', @@ -104,7 +104,7 @@ DATABASES = { ``` ### Run the server -With those steps out of the way, and having successfully setup both healthchecks and properly installed django-spanner, we are now ready to get started +With those steps out of the way, and having successfully setup both healthchecks and properly installed django-google-spanner, we are now ready to get started ```shell (hc-venv) $ python3 manage.py runserver @@ -301,4 +301,4 @@ Resource|URL Healthchecks app|https://healthchecks.io/ Healthchecks source code|https://github.com/healthchecks/healthchecks/ Cloud Spanner homepage|https://cloud.google.com/spanner/ -django-spanner project's source code|https://github.com/googleapis/python-spanner-django/ +django-google-spanner project's source code|https://github.com/googleapis/python-spanner-django/ diff --git a/google/cloud/spanner_dbapi/version.py b/google/cloud/spanner_dbapi/version.py index bf67a4fca8..764f5ebcf7 100644 --- a/google/cloud/spanner_dbapi/version.py +++ b/google/cloud/spanner_dbapi/version.py @@ -9,7 +9,7 @@ from google.api_core.gapic_v1.client_info import ClientInfo VERSION = "0.0.1" -DEFAULT_USER_AGENT = "django_spanner/" + VERSION +DEFAULT_USER_AGENT = "django_google_spanner/" + VERSION vers = sys.version_info diff --git a/noxfile.py b/noxfile.py index 552ce47562..4506423bab 100644 --- a/noxfile.py +++ b/noxfile.py @@ -16,7 +16,7 @@ BLACK_VERSION = "black==19.10b0" BLACK_PATHS = [ - "django_spanner", + "django_google_spanner", "docs", "google", "tests", @@ -34,7 +34,7 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run("black", "--check", *BLACK_PATHS) - session.run("flake8", "django_spanner", "google", "tests") + session.run("flake8", "django_google_spanner", "google", "tests") @nox.session(python="3.8") @@ -69,7 +69,7 @@ def default(session): session.run( "py.test", "--quiet", - "--cov=django_spanner", + "--cov=django_google_spanner", "--cov=google.cloud", "--cov=tests.spanner_dbapi", "--cov-append", From 62e01498ddd080949190e17044b45ae3fc34bb4e Mon Sep 17 00:00:00 2001 From: "STATION\\mf" Date: Fri, 11 Sep 2020 18:53:20 -0400 Subject: [PATCH 4/4] fix: updated database backend name --- django_test_suite.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django_test_suite.sh b/django_test_suite.sh index 4201b15893..8cbe8e6ac3 100755 --- a/django_test_suite.sh +++ b/django_test_suite.sh @@ -23,13 +23,13 @@ create_settings() { cat << ! > "$SETTINGS_FILE.py" DATABASES = { 'default': { - 'ENGINE': 'django_google_spanner', + 'ENGINE': 'django.google.spanner', 'PROJECT': "$PROJECT", 'INSTANCE': "$INSTANCE", 'NAME': "$TEST_DBNAME", }, 'other': { - 'ENGINE': 'django_google_spanner', + 'ENGINE': 'django.google.spanner', 'PROJECT': "$PROJECT", 'INSTANCE': "$INSTANCE", 'NAME': "$TEST_DBNAME_OTHER",