Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on May 14, 2026. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 35
feat: support sequences#336
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b13ba9b
feat: support sequences in sqlalchemy spanner
harshachinta 4460f66
feat: remove unsupported test in 1.3
harshachinta 02f7719
feat: dummy commit for running build
harshachinta bad117b
feat: skip emulator tests
harshachinta f2824c6
feat: skip emulator tests for sequences
harshachinta 855f1c0
feat: fix lint
harshachinta b093588
feat: fix lint
harshachinta b4dcf32
feat: remove unused imports
harshachinta d41f082
feat: remove space
harshachinta 7ee8a21
feat: fix lint
harshachinta ddcb01d
feat: fix lint
harshachinta 0c1885c
fix: lint
harshachinta f8e9705
fix: lint
harshachinta 10bac02
feat: remove unchanged tests and lint
harshachinta 73d68d6
docs: add comments
harshachinta c1501d3
Merge branch 'main' into support-sequences
harshachinta 538012c
Merge branch 'main' into support-sequences
harshachinta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -37,6 +37,7 @@ | ||
| from sqlalchemy.testing import config | ||
| from sqlalchemy.testing import engines | ||
| from sqlalchemy.testing import eq_ | ||
| from sqlalchemy.testing import is_instance_of | ||
| from sqlalchemy.testing import provide_metadata, emits_warning | ||
| from sqlalchemy.testing import fixtures | ||
| from sqlalchemy.testing import is_true | ||
| @@ -73,7 +74,10 @@ | ||
| from sqlalchemy.testing.suite.test_reflection import * # noqa: F401, F403 | ||
| from sqlalchemy.testing.suite.test_results import * # noqa: F401, F403 | ||
| from sqlalchemy.testing.suite.test_select import * # noqa: F401, F403 | ||
| from sqlalchemy.testing.suite.test_sequence import * # noqa: F401, F403 | ||
| from sqlalchemy.testing.suite.test_sequence import ( | ||
| SequenceTest as _SequenceTest, | ||
| HasSequenceTest as _HasSequenceTest, | ||
| ) # noqa: F401, F403 | ||
| from sqlalchemy.testing.suite.test_update_delete import * # noqa: F401, F403 | ||
| from sqlalchemy.testing.suite.test_cte import CTETest as _CTETest | ||
| @@ -2059,3 +2063,124 @@ def test_create_engine_wo_database(self): | ||
| engine = create_engine(get_db_url().split("/database")[0]) | ||
| with engine.connect() as connection: | ||
| assert connection.connection.database is None | ||
| @pytest.mark.skipif( | ||
| bool(os.environ.get("SPANNER_EMULATOR_HOST")), reason="Skipped on emulator" | ||
| ) | ||
| class SequenceTest(_SequenceTest): | ||
| @classmethod | ||
| def define_tables(cls, metadata): | ||
| Table( | ||
| "seq_pk", | ||
| metadata, | ||
| Column( | ||
| "id", | ||
| Integer, | ||
| sqlalchemy.Sequence("tab_id_seq"), | ||
| primary_key=True, | ||
| ), | ||
| Column("data", String(50)), | ||
| ) | ||
| Table( | ||
| "seq_opt_pk", | ||
| metadata, | ||
| Column( | ||
| "id", | ||
| Integer, | ||
| sqlalchemy.Sequence("tab_id_seq_opt", data_type=Integer, optional=True), | ||
| primary_key=True, | ||
| ), | ||
| Column("data", String(50)), | ||
| ) | ||
| Table( | ||
| "seq_no_returning", | ||
| metadata, | ||
| Column( | ||
| "id", | ||
| Integer, | ||
| sqlalchemy.Sequence("noret_id_seq"), | ||
| primary_key=True, | ||
| ), | ||
| Column("data", String(50)), | ||
| implicit_returning=False, | ||
| ) | ||
| def test_insert_lastrowid(self, connection): | ||
| r = connection.execute(self.tables.seq_pk.insert(), dict(data="some data")) | ||
| assert len(r.inserted_primary_key) == 1 | ||
| is_instance_of(r.inserted_primary_key[0], int) | ||
| def test_nextval_direct(self, connection): | ||
| r = connection.execute(self.tables.seq_pk.c.id.default) | ||
| is_instance_of(r, int) | ||
harshachinta marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| def _assert_round_trip(self, table, conn): | ||
| row = conn.execute(table.select()).first() | ||
| id, name = row | ||
| is_instance_of(id, int) | ||
| eq_(name, "some data") | ||
| @testing.combinations((True,), (False,), argnames="implicit_returning") | ||
| @testing.requires.schemas | ||
| @pytest.mark.skip("Not supported by Cloud Spanner") | ||
| def test_insert_roundtrip_translate(self, connection, implicit_returning): | ||
| pass | ||
| @testing.requires.schemas | ||
| @pytest.mark.skip("Not supported by Cloud Spanner") | ||
| def test_nextval_direct_schema_translate(self, connection): | ||
| pass | ||
| @pytest.mark.skipif( | ||
| bool(os.environ.get("SPANNER_EMULATOR_HOST")), reason="Skipped on emulator" | ||
| ) | ||
| class HasSequenceTest(_HasSequenceTest): | ||
| @classmethod | ||
| def define_tables(cls, metadata): | ||
| sqlalchemy.Sequence("user_id_seq", metadata=metadata) | ||
| sqlalchemy.Sequence( | ||
| "other_seq", metadata=metadata, nomaxvalue=True, nominvalue=True | ||
| ) | ||
| Table( | ||
| "user_id_table", | ||
| metadata, | ||
| Column("id", Integer, primary_key=True), | ||
| ) | ||
| @pytest.mark.skip("Not supported by Cloud Spanner") | ||
| def test_has_sequence_cache(self, connection, metadata): | ||
| pass | ||
| @testing.requires.schemas | ||
| @pytest.mark.skip("Not supported by Cloud Spanner") | ||
| def test_has_sequence_schema(self, connection): | ||
| pass | ||
| @testing.requires.schemas | ||
| @pytest.mark.skip("Not supported by Cloud Spanner") | ||
| def test_has_sequence_schemas_neg(self, connection): | ||
| pass | ||
| @testing.requires.schemas | ||
| @pytest.mark.skip("Not supported by Cloud Spanner") | ||
| def test_has_sequence_default_not_in_remote(self, connection): | ||
| pass | ||
| @testing.requires.schemas | ||
| @pytest.mark.skip("Not supported by Cloud Spanner") | ||
| def test_has_sequence_remote_not_in_default(self, connection): | ||
| pass | ||
| @testing.requires.schemas | ||
| @pytest.mark.skip("Not supported by Cloud Spanner") | ||
| def test_get_sequence_names_no_sequence_schema(self, connection): | ||
| pass | ||
| @testing.requires.schemas | ||
| @pytest.mark.skip("Not supported by Cloud Spanner") | ||
| def test_get_sequence_names_sequences_schema(self, connection): | ||
| pass | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.