diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2020-09-12 16:26:39 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-09-12 16:26:39 +0000 |
| commit | dad484e7fab006c5c951cd7e8134772d050ccff2 (patch) | |
| tree | 47d176074999835f3f5820347e0fc357188a7444 /lib/sqlalchemy/dialects | |
| parent | f53e5fc7cb408f067d18e7f3eabf993bd1887063 (diff) | |
| parent | 1d40a4ae159086b9ff6452a310d4cd57ef850813 (diff) | |
| download | sqlalchemy-dad484e7fab006c5c951cd7e8134772d050ccff2.tar.gz | |
Merge "Do not specify type on mssql by default"
Diffstat (limited to 'lib/sqlalchemy/dialects')
| -rw-r--r-- | lib/sqlalchemy/dialects/mssql/base.py | 34 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 1 |
3 files changed, 19 insertions, 18 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 505a6c772..b398610b2 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -242,9 +242,8 @@ SEQUENCE support The :class:`.Sequence` object now creates "real" sequences, i.e., ``CREATE SEQUENCE``. To provide compatibility with other dialects, -:class:`.Sequence` defaults to a data type of Integer and a start value of 1, -even though the T-SQL defaults are BIGINT and -9223372036854775808, -respectively. +:class:`.Sequence` defaults to a start value of 1, even though the +T-SQL defaults is -9223372036854775808. .. versionadded:: 1.4.0 @@ -757,7 +756,6 @@ from ...sql import func from ...sql import quoted_name from ...sql import roles from ...sql import util as sql_util -from ...sql.type_api import to_instance from ...types import BIGINT from ...types import BINARY from ...types import CHAR @@ -1639,6 +1637,16 @@ class MSExecutionContext(default.DefaultExecutionContext): type_, ) + def get_insert_default(self, column): + if ( + isinstance(column, sa_schema.Column) + and column is column.table._autoincrement_column + and isinstance(column.default, sa_schema.Sequence) + and column.default.optional + ): + return None + return super(MSExecutionContext, self).get_insert_default(column) + class MSSQLCompiler(compiler.SQLCompiler): returning_precedes_values = True @@ -2204,11 +2212,10 @@ class MSDDLCompiler(compiler.DDLCompiler): elif ( column is column.table._autoincrement_column or column.autoincrement is True + ) and ( + not isinstance(column.default, Sequence) or column.default.optional ): - if not isinstance(column.default, Sequence): - colspec += self.process( - Identity(start=start, increment=increment) - ) + colspec += self.process(Identity(start=start, increment=increment)) else: default = self.get_column_default_string(column) if default is not None: @@ -2332,13 +2339,10 @@ class MSDDLCompiler(compiler.DDLCompiler): return text def visit_create_sequence(self, create, **kw): - + prefix = None if create.element.data_type is not None: data_type = create.element.data_type - else: - data_type = to_instance(self.dialect.sequence_default_column_type) - - prefix = " AS %s" % self.type_compiler.process(data_type) + prefix = " AS %s" % self.type_compiler.process(data_type) return super(MSDDLCompiler, self).visit_create_sequence( create, prefix=prefix, **kw ) @@ -2547,8 +2551,7 @@ class MSDialect(default.DefaultDialect): ischema_names = ischema_names supports_sequences = True - # T-SQL's actual default is BIGINT - sequence_default_column_type = INTEGER + sequences_optional = True # T-SQL's actual default is -9223372036854775808 default_sequence_base = 1 @@ -3148,7 +3151,6 @@ class MSDialect(default.DefaultDialect): RR = ischema.ref_constraints C = ischema.key_constraints.alias("C") R = ischema.key_constraints.alias("R") - # Foreign key constraints s = ( sql.select( diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 49ff0c14a..130aeeb0f 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -2432,7 +2432,7 @@ class MySQLDialect(default.DefaultDialect): supports_sequences = False # default for MySQL ... # ... may be updated to True for MariaDB 10.3+ in initialize() - sequences_optional = True + sequences_optional = False supports_for_update_of = False # default for MySQL ... # ... may be updated to True for MySQL 8+ in initialize() diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 819f1238a..93ee7ca29 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -2695,7 +2695,6 @@ class PGDialect(default.DefaultDialect): supports_sequences = True sequences_optional = True - sequence_default_column_type = INTEGER preexecute_autoincrement_sequences = True postfetch_lastrowid = False |
