diff options
author | Federico Caselli <cfederico87@gmail.com> | 2020-09-19 22:29:38 +0200 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-09-28 18:11:12 -0400 |
commit | 7362d454f46107cae4076ce54e9fa430c3370734 (patch) | |
tree | ae7545a99a76995ef31a879f09fb1c0fe6764f4b /test/dialect/oracle/test_compiler.py | |
parent | c3f102c9fe9811fd5286628cc6aafa5fbc324621 (diff) | |
download | sqlalchemy-7362d454f46107cae4076ce54e9fa430c3370734.tar.gz |
Add reflection for Identity columns
Added support for reflecting "identity" columns, which are now returned
as part of the structure returned by :meth:`_reflection.Inspector.get_columns`.
When reflecting full :class:`_schema.Table` objects, identity columns will
be represented using the :class:`_schema.Identity` construct.
Fixed compilation error on oracle for sequence and identity column
``nominvalue`` and ``nomaxvalue`` options that require no space in them.
Improved test compatibility with oracle 18.
As part of the support for reflecting :class:`_schema.Identity` objects,
the method :meth:`_reflection.Inspector.get_columns` no longer returns
``mssql_identity_start`` and ``mssql_identity_increment`` as part of the
``dialect_options``. Use the information in the ``identity`` key instead.
The mssql dialect will assume that at least MSSQL 2005 is used.
There is no hard exception raised if a previous version is detected,
but operations may fail for older versions.
Fixes: #5527
Fixes: #5324
Change-Id: If039fe637c46b424499e6bac54a2cbc0dc54cb57
Diffstat (limited to 'test/dialect/oracle/test_compiler.py')
-rw-r--r-- | test/dialect/oracle/test_compiler.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/test/dialect/oracle/test_compiler.py b/test/dialect/oracle/test_compiler.py index cea2b5141..869cffe44 100644 --- a/test/dialect/oracle/test_compiler.py +++ b/test/dialect/oracle/test_compiler.py @@ -28,6 +28,7 @@ from sqlalchemy.dialects.oracle import base as oracle from sqlalchemy.dialects.oracle import cx_oracle from sqlalchemy.engine import default from sqlalchemy.sql import column +from sqlalchemy.sql import ddl from sqlalchemy.sql import quoted_name from sqlalchemy.sql import table from sqlalchemy.testing import assert_raises_message @@ -1258,12 +1259,22 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): t = Table( "t", m, - Column("y", Integer, Identity(always=True, start=4, increment=7)), + Column( + "y", + Integer, + Identity( + always=True, + start=4, + increment=7, + nominvalue=True, + nomaxvalue=True, + ), + ), ) self.assert_compile( schema.CreateTable(t), "CREATE TABLE t (y INTEGER GENERATED ALWAYS AS IDENTITY " - "(INCREMENT BY 7 START WITH 4))", + "(INCREMENT BY 7 START WITH 4 NOMINVALUE NOMAXVALUE))", ) def test_column_identity_no_generated(self): @@ -1310,6 +1321,15 @@ class SequenceTest(fixtures.TestBase, AssertsCompiledSQL): == '"Some_Schema"."My_Seq"' ) + def test_compile(self): + self.assert_compile( + ddl.CreateSequence( + Sequence("my_seq", nomaxvalue=True, nominvalue=True) + ), + "CREATE SEQUENCE my_seq START WITH 1 NOMINVALUE NOMAXVALUE", + dialect=oracle.OracleDialect(), + ) + class RegexpTest(fixtures.TestBase, testing.AssertsCompiledSQL): __dialect__ = "oracle" |