sqlalchemy-spanner 1.19.0__tar.gz → 1.20.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/PKG-INFO +1 -1
  2. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/google/cloud/sqlalchemy_spanner/__init__.py +6 -2
  3. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py +31 -5
  4. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/google/cloud/sqlalchemy_spanner/version.py +1 -1
  5. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/sqlalchemy_spanner.egg-info/PKG-INFO +1 -1
  6. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/tests/test_suite_14.py +10 -8
  7. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/LICENSE +0 -0
  8. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/README.rst +0 -0
  9. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/google/cloud/sqlalchemy_spanner/_opentelemetry_tracing.py +0 -0
  10. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/google/cloud/sqlalchemy_spanner/dml.py +0 -0
  11. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/google/cloud/sqlalchemy_spanner/provision.py +0 -0
  12. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/google/cloud/sqlalchemy_spanner/requirements.py +0 -0
  13. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/setup.cfg +0 -0
  14. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/setup.py +0 -0
  15. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/sqlalchemy_spanner.egg-info/SOURCES.txt +0 -0
  16. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/sqlalchemy_spanner.egg-info/dependency_links.txt +0 -0
  17. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/sqlalchemy_spanner.egg-info/entry_points.txt +0 -0
  18. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/sqlalchemy_spanner.egg-info/not-zip-safe +0 -0
  19. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/sqlalchemy_spanner.egg-info/requires.txt +0 -0
  20. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/sqlalchemy_spanner.egg-info/top_level.txt +0 -0
  21. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/tests/test_suite_13.py +0 -0
  22. {sqlalchemy_spanner-1.19.0 → sqlalchemy_spanner-1.20.0}/tests/test_suite_20.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlalchemy-spanner
3
- Version: 1.19.0
3
+ Version: 1.20.0
4
4
  Summary: SQLAlchemy dialect integrated into Cloud Spanner database
5
5
  Home-page: https://github.com/cloudspannerecosystem/python-spanner-sqlalchemy
6
6
  Author: Google LLC
@@ -12,7 +12,11 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- from .sqlalchemy_spanner import SpannerDialect
15
+ from .sqlalchemy_spanner import MAX_SIZE, SpannerDialect
16
16
  from .version import __version__
17
17
 
18
- __all__ = (SpannerDialect, __version__)
18
+ __all__ = (
19
+ "MAX_SIZE",
20
+ "SpannerDialect",
21
+ "__version__",
22
+ )
@@ -120,8 +120,12 @@ _type_map = {
120
120
  "TIMESTAMP": types.TIMESTAMP,
121
121
  "ARRAY": types.ARRAY,
122
122
  "JSON": types.JSON,
123
+ "TOKENLIST": types.String,
123
124
  }
124
125
 
126
+ if hasattr(types, "UUID"):
127
+ _type_map["UUID"] = types.UUID
128
+
125
129
 
126
130
  _type_map_inv = {
127
131
  types.Boolean: "BOOL",
@@ -140,6 +144,12 @@ _type_map_inv = {
140
144
  types.NullType: "INT64",
141
145
  }
142
146
 
147
+ if hasattr(types, "UUID"):
148
+ _type_map_inv[types.UUID] = "UUID"
149
+
150
+ if hasattr(types, "Uuid"):
151
+ _type_map_inv[types.Uuid] = "UUID"
152
+
143
153
  _compound_keywords = {
144
154
  selectable.CompoundSelect.UNION: "UNION DISTINCT",
145
155
  selectable.CompoundSelect.UNION_ALL: "UNION ALL",
@@ -149,7 +159,10 @@ _compound_keywords = {
149
159
  selectable.CompoundSelect.INTERSECT_ALL: "INTERSECT ALL",
150
160
  }
151
161
 
152
- _max_size = 2621440
162
+ #: Maximum allowable character/byte length for Cloud Spanner STRING(MAX) and
163
+ #: BYTES(MAX) DDL data types (2.5 MiB = 2,621,440 bytes).
164
+ MAX_SIZE = 2621440
165
+ _max_size = MAX_SIZE
153
166
 
154
167
 
155
168
  def int_from_size(size_str):
@@ -161,7 +174,7 @@ def int_from_size(size_str):
161
174
  Returns:
162
175
  int: The column length value.
163
176
  """
164
- return _max_size if size_str == "MAX" else int(size_str)
177
+ return MAX_SIZE if size_str == "MAX" else int(size_str)
165
178
 
166
179
 
167
180
  def engine_to_connection(function):
@@ -426,8 +439,10 @@ class SpannerSQLCompiler(SQLCompiler):
426
439
  )
427
440
  for c in expression._select_iterables(
428
441
  filter(
429
- lambda col: not col.dialect_options.get("spanner", {}).get(
430
- "exclude_from_returning", False
442
+ lambda col: (
443
+ not col.dialect_options.get("spanner", {}).get(
444
+ "exclude_from_returning", False
445
+ )
431
446
  ),
432
447
  returning_cols,
433
448
  )
@@ -762,6 +777,12 @@ class SpannerTypeCompiler(GenericTypeCompiler):
762
777
  Maps SQLAlchemy types to Spanner data types.
763
778
  """
764
779
 
780
+ def visit_uuid(self, type_, **kw):
781
+ if not type_.native_uuid or not self.dialect.supports_native_uuid:
782
+ return self.visit_CHAR(types.CHAR(36), **kw)
783
+ else:
784
+ return self.visit_UUID(type_, **kw)
785
+
765
786
  def visit_INTEGER(self, type_, **kw):
766
787
  return "INT64"
767
788
 
@@ -830,6 +851,7 @@ class SpannerDialect(DefaultDialect):
830
851
  paramstyle = "format"
831
852
  encoding = "utf-8"
832
853
  max_identifier_length = 256
854
+ max_size = MAX_SIZE
833
855
  _legacy_binary_type_literal_encoding = "utf-8"
834
856
  _default_isolation_level = "SERIALIZABLE"
835
857
 
@@ -844,6 +866,7 @@ class SpannerDialect(DefaultDialect):
844
866
  supports_identity_columns = True
845
867
  supports_native_boolean = True
846
868
  supports_native_decimal = True
869
+ supports_native_uuid = False
847
870
  supports_statement_cache = True
848
871
  # Spanner uses protos for enums. Creating a column like
849
872
  # Column("an_enum", Enum("A", "B", "C")) will result in a String
@@ -1300,6 +1323,7 @@ class SpannerDialect(DefaultDialect):
1300
1323
  {table_type_query}
1301
1324
  {schema_filter_query}
1302
1325
  i.index_type != 'PRIMARY_KEY'
1326
+ AND i.index_type != 'SEARCH'
1303
1327
  AND i.spanner_is_managed = FALSE
1304
1328
  GROUP BY i.table_catalog, i.table_schema, i.table_name,
1305
1329
  i.index_name, i.is_unique
@@ -1324,7 +1348,9 @@ class SpannerDialect(DefaultDialect):
1324
1348
  "column_names": row[3],
1325
1349
  "unique": row[4],
1326
1350
  "column_sorting": {
1327
- col: order.lower() for col, order in zip(row[3], row[5])
1351
+ col: order.lower()
1352
+ for col, order in zip(row[3], row[5] or [])
1353
+ if order
1328
1354
  },
1329
1355
  "include_columns": include_columns if include_columns else [],
1330
1356
  "dialect_options": dialect_options,
@@ -4,4 +4,4 @@
4
4
  # license that can be found in the LICENSE file or at
5
5
  # https://developers.google.com/open-source/licenses/bsd
6
6
 
7
- __version__ = "1.19.0"
7
+ __version__ = "1.20.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlalchemy-spanner
3
- Version: 1.19.0
3
+ Version: 1.20.0
4
4
  Summary: SQLAlchemy dialect integrated into Cloud Spanner database
5
5
  Home-page: https://github.com/cloudspannerecosystem/python-spanner-sqlalchemy
6
6
  Author: Google LLC
@@ -25,7 +25,9 @@ from unittest import mock
25
25
  import pytest
26
26
  import sqlalchemy
27
27
  from google.api_core.datetime_helpers import DatetimeWithNanoseconds
28
+ from google.cloud import spanner_dbapi
28
29
  from google.cloud.spanner_v1 import Client, RequestOptions
30
+ from google.cloud.sqlalchemy_spanner import version as sqlalchemy_spanner_version
29
31
  from sqlalchemy import (
30
32
  FLOAT,
31
33
  Boolean,
@@ -204,8 +206,6 @@ from sqlalchemy.testing.suite.test_update_delete import (
204
206
  )
205
207
  from sqlalchemy.types import Integer, Numeric, Text
206
208
 
207
- from google.cloud import spanner_dbapi
208
- from google.cloud.sqlalchemy_spanner import version as sqlalchemy_spanner_version
209
209
  from tests._helpers import get_db_url, get_project
210
210
 
211
211
  config.test_schema = ""
@@ -250,7 +250,7 @@ class ComponentReflectionTestExtra(_ComponentReflectionTestExtra):
250
250
  @testing.requires.table_reflection
251
251
  def test_nullable_reflection(self, connection, metadata):
252
252
  t = Table(
253
- "t",
253
+ "t_nullable_reflection",
254
254
  metadata,
255
255
  Column("a", Integer, nullable=True),
256
256
  Column("b", Integer, nullable=False),
@@ -260,19 +260,21 @@ class ComponentReflectionTestExtra(_ComponentReflectionTestExtra):
260
260
  eq_(
261
261
  dict(
262
262
  (col["name"], col["nullable"])
263
- for col in inspect(connection).get_columns("t")
263
+ for col in inspect(connection).get_columns("t_nullable_reflection")
264
264
  ),
265
265
  {"a": True, "b": False},
266
266
  )
267
267
 
268
268
  def _type_round_trip(self, connection, metadata, *types):
269
269
  t = Table(
270
- "t", metadata, *[Column("t%d" % i, type_) for i, type_ in enumerate(types)]
270
+ "t_type_round_trip",
271
+ metadata,
272
+ *[Column("t%d" % i, type_) for i, type_ in enumerate(types)],
271
273
  )
272
274
  t.create(connection)
273
275
  connection.connection.commit()
274
276
 
275
- return [c["type"] for c in inspect(connection).get_columns("t")]
277
+ return [c["type"] for c in inspect(connection).get_columns("t_type_round_trip")]
276
278
 
277
279
  @testing.requires.table_reflection
278
280
  def test_numeric_reflection(self, connection, metadata):
@@ -1207,7 +1209,7 @@ class EscapingTest(_EscapingTest):
1207
1209
  Overriding the test to avoid the same failure.
1208
1210
  """
1209
1211
  m = self.metadata
1210
- t = Table("t", m, Column("data", String(50)))
1212
+ t = Table("t_percent_signs", m, Column("data", String(50)))
1211
1213
  t.create(config.db)
1212
1214
  with config.db.begin() as conn:
1213
1215
  conn.execute(t.insert(), dict(data="some % value"))
@@ -1551,7 +1553,7 @@ class NumericTest(_NumericTest):
1551
1553
  @testing.emits_warning(r".*does \*not\* support Decimal objects natively")
1552
1554
  def run(type_, input_, output, filter_=None, check_scale=False):
1553
1555
  t = Table(
1554
- "t",
1556
+ "t_do_numeric",
1555
1557
  metadata,
1556
1558
  Column("x", type_),
1557
1559
  Column("id", Integer, primary_key=True),