strings and sa.text() have a different behavior in server_default #1433
-
Hello, I use Alembic 1.3.1 (latest version) and the from alembic import op
import sqlalchemy as sa
revision = 'ab743bfca885'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'test_alembic',
sa.Column('with_sa_text', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('with_str', sa.DateTime(), server_default='now()', nullable=False),
)
def downgrade():
op.drop_table('test_alembic') If I execute the above migration with
The two columns have a different default: the one using I haven’t seen anything about this in the docs; is it a bug? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
no bug, if you send a string for a server_default, that's a literal default, just like if you sent an integer or a float. docs are here https://docs.sqlalchemy.org/en/20/core/metadata.html#sqlalchemy.schema.Column.params.server_default |
Beta Was this translation helpful? Give feedback.
no bug, if you send a string for a server_default, that's a literal default, just like if you sent an integer or a float. docs are here https://docs.sqlalchemy.org/en/20/core/metadata.html#sqlalchemy.schema.Column.params.server_default