You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
INFO [sqlalchemy.engine.base.Engine] ()
2021-03-04 08:55:50,868 INFO sqlalchemy.engine.base.Engine ALTER TABLE store.[NewClients] ALTER COLUMN id INTEGER NOT NULL
INFO [sqlalchemy.engine.base.Engine] ALTER TABLE store.[NewClients] ALTER COLUMN id INTEGER NOT NULL
2021-03-04 08:55:50,869 INFO sqlalchemy.engine.base.Engine ()
INFO [sqlalchemy.engine.base.Engine] ()
2021-03-04 08:55:50,873 INFO sqlalchemy.engine.base.Engine ALTER TABLE store.[NewClients] ALTER COLUMN id VARCHAR(15)
INFO [sqlalchemy.engine.base.Engine] ALTER TABLE store.[NewClients] ALTER COLUMN id VARCHAR(15)
2021-03-04 08:55:50,873 INFO sqlalchemy.engine.base.Engine ()
and as a result the column id has now type VARCHAR(15) NULL and the creation of primary key fails (because primary key columns cannot be NULL).
Is this the intended behavior? If it is, would it be possible to add some sort of notice or warning regarding the use of parameter existing_type in alter_column with MSSQL to documentation?
Versions.
OS: Win 10
Python: 3.8.3
Alembic: 1.5.5
SQLAlchemy: 1.3.23
Database: SQL Server 14.0.3281.6 (2017, Linux)
DBAPI: pyodbc
The text was updated successfully, but these errors were encountered:
zzzeek
changed the title
Confusing behavior with existing_type parameter in alter_column operation with MSSQL
mssql dialect not anticipating existing_type + type sent at the same time
Mar 4, 2021
that's just a simple bug, MSSQL can alter the type + nullability in one statement, which is distinct from the default logic that can only set them in separate statements, and the logic it uses to detect this simply didn't anticipate existing_type being present. thanks for the bug report.
Hello,
I have the following table in my MSSQL database:
I wish to alter the data type of column
id
to VARCHAR(15) NOT NULL. I expected the following commands to produce the same result:The first one works perfectly
However, if I add the
existing_type
parameter toalter_column
operation, things become confusing...This produces
and as a result the column
id
has now type VARCHAR(15) NULL and the creation of primary key fails (because primary key columns cannot be NULL).Is this the intended behavior? If it is, would it be possible to add some sort of notice or warning regarding the use of parameter
existing_type
inalter_column
with MSSQL to documentation?Versions.
The text was updated successfully, but these errors were encountered: