[Sqlalchemy-tickets] Issue #3979: Sequence doesn't inherit schema from metadata (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
From: Alistair W. <iss...@bi...> - 2017-05-05 16:12:15
|
New issue 3979: Sequence doesn't inherit schema from metadata https://bitbucket.org/zzzeek/sqlalchemy/issues/3979/sequence-doesnt-inherit-schema-from Alistair Watson: The code below emits: ``` #!python CREATE SEQUENCE test_sequence ``` when according to the documentation it should get it's default schema value from the metadata and it should emit: ``` #!python CREATE SEQUENCE test_schema.test_sequence ``` It's not really an issue if you are connecting as the user/schema you want to own the sequence - unfortunately I need to create all tables and database objects as a different user. Providing the schema parameter to each sequence directly does solve the issue. ``` #!python from sqlalchemy import create_engine, MetaData, Column, Integer,Sequence from sqlalchemy.ext.declarative import declarative_base engine = create_engine('oracle+cx_oracle://test_schema:Welcome1@localhost:1521/xe', echo=True) metadata = MetaData(schema='test_schema') Base = declarative_base(metadata=metadata) class Child(Base): __tablename__ = 'child' id = Column(Integer, Sequence(name="test_sequence"), primary_key=True) data = Column(Integer) Base.metadata.drop_all(engine, checkfirst = True) Base.metadata.create_all(engine) ``` |