示例#1
0
    def test_drop_unique_constraint_change_name(self):
        schema_obj = schemaobj.SchemaObjects()
        const = schema_obj.unique_constraint("x", "foobar", ["a"])
        op = ops.DropConstraintOp.from_constraint(const)

        op.constraint_name = "my_name"
        eq_(op.to_constraint().name, "my_name")
        eq_(op.reverse().to_constraint().name, "my_name")
示例#2
0
    def test_create_table_add_kw(self):
        schema_obj = schemaobj.SchemaObjects()
        table = schema_obj.table("x", Column("q", Integer))
        op = ops.CreateTableOp.from_table(table)
        op.kw["postgresql_partition_by"] = "x"

        eq_(op.to_table().dialect_kwargs["postgresql_partition_by"], "x")
        eq_(
            op.reverse().to_table().dialect_kwargs["postgresql_partition_by"],
            "x",
        )
示例#3
0
    def test_create_index_add_kw(self):
        schema_obj = schemaobj.SchemaObjects()
        idx = schema_obj.index("x", "y", ["z"])
        op = ops.CreateIndexOp.from_index(idx)

        op.kw["postgresql_concurrently"] = True

        eq_(op.to_index().dialect_kwargs["postgresql_concurrently"], True)
        eq_(
            op.reverse().to_index().dialect_kwargs["postgresql_concurrently"],
            True,
        )
示例#4
0
    def test_create_unique_constraint_add_kw(self):
        schema_obj = schemaobj.SchemaObjects()
        const = schema_obj.unique_constraint("x", "foobar", ["a"])
        op = ops.AddConstraintOp.from_constraint(const)
        is_not_(op.to_constraint(), const)

        op.kw["sqlite_on_conflict"] = "IGNORE"

        eq_(op.to_constraint().dialect_kwargs["sqlite_on_conflict"], "IGNORE")
        eq_(
            op.reverse().to_constraint().dialect_kwargs["sqlite_on_conflict"],
            "IGNORE",
        )
示例#5
0
 def test_create_table(self):
     schema_obj = schemaobj.SchemaObjects()
     table = schema_obj.table(
         "x",
         Column("q", Integer),
         postgresql_partition_by="x",
         prefixes=["FOREIGN"],
         info={"custom": "value"},
         comment="some comment",
     )
     op = ops.CreateTableOp.from_table(table)
     is_not_(op.to_table(), table)
     eq_(op.to_table().comment, table.comment)
     eq_(op.to_table().info, table.info)
     eq_(op.to_table()._prefixes, table._prefixes)
示例#6
0
文件: test_op.py 项目: lkpdn/alembic
 def test_drop_unique_constraint(self):
     schema_obj = schemaobj.SchemaObjects()
     const = schema_obj.unique_constraint("x", "foobar", ["a"])
     op = ops.DropConstraintOp.from_constraint(const)
     is_(op.to_constraint(), const)
示例#7
0
文件: test_op.py 项目: lkpdn/alembic
 def test_create_table(self):
     schema_obj = schemaobj.SchemaObjects()
     table = schema_obj.table("x", Column("q", Integer))
     op = ops.CreateTableOp.from_table(table)
     is_(op.to_table(), table)
示例#8
0
文件: test_op.py 项目: lkpdn/alembic
 def test_create_index(self):
     schema_obj = schemaobj.SchemaObjects()
     idx = schema_obj.index("x", "y", ["z"])
     op = ops.CreateIndexOp.from_index(idx)
     is_(op.to_index(), idx)
示例#9
0
 def test_drop_unique_constraint(self):
     schema_obj = schemaobj.SchemaObjects()
     const = schema_obj.unique_constraint('x', 'foobar', ['a'])
     op = ops.DropConstraintOp.from_constraint(const)
     is_(op.to_constraint(), const)
示例#10
0
 def test_drop_table(self):
     schema_obj = schemaobj.SchemaObjects()
     table = schema_obj.table('x', Column('q', Integer))
     op = ops.DropTableOp.from_table(table)
     is_(op.to_table(), table)
示例#11
0
 def test_create_index(self):
     schema_obj = schemaobj.SchemaObjects()
     idx = schema_obj.index('x', 'y', ['z'])
     op = ops.CreateIndexOp.from_index(idx)
     is_(op.to_index(), idx)
示例#12
0
 def test_create_unique_constraint(self):
     schema_obj = schemaobj.SchemaObjects()
     const = schema_obj.unique_constraint("x", "foobar", ["a"])
     op = ops.AddConstraintOp.from_constraint(const)
     is_not_(op.to_constraint(), const)
示例#13
0
 def test_drop_index(self):
     schema_obj = schemaobj.SchemaObjects()
     idx = schema_obj.index("x", "y", ["z"])
     op = ops.DropIndexOp.from_index(idx)
     is_not_(op.to_index(), idx)