Exemplo n.º 1
0
 def test_add_check_constraint(self):
     context = op_fixture()
     op.create_check_constraint("ck_user_name_len", "user_table",
                                func.len(column("name")) > 5)
     context.assert_(
         "ALTER TABLE user_table ADD CONSTRAINT ck_user_name_len "
         "CHECK (len(name) > 5)")
Exemplo n.º 2
0
def test_add_check_constraint():
    context = op_fixture(
        naming_convention={"ck": "ck_%(table_name)s_%(constraint_name)s"})
    op.create_check_constraint("foo", "user_table",
                               func.len(column('name')) > 5)
    context.assert_("ALTER TABLE user_table ADD CONSTRAINT ck_user_table_foo "
                    "CHECK (len(name) > 5)")
Exemplo n.º 3
0
 def test_add_check_constraint_schema(self):
     context = op_fixture()
     op.create_check_constraint("ck_user_name_len",
                                "user_table",
                                func.len(column('name')) > 5,
                                schema='foo')
     context.assert_(
         "ALTER TABLE foo.user_table ADD CONSTRAINT ck_user_name_len "
         "CHECK (len(name) > 5)")
Exemplo n.º 4
0
 def test_add_check_constraint(self):
     context = op_fixture()
     op.create_check_constraint(
         "ck_user_name_len", "user_table", func.len(column("name")) > 5
     )
     context.assert_(
         "ALTER TABLE user_table ADD CONSTRAINT ck_user_name_len "
         "CHECK (len(name) > 5)"
     )
Exemplo n.º 5
0
 def test_add_check_constraint_name_is_none(self):
     context = op_fixture(naming_convention={"ck": "ck_%(table_name)s_foo"})
     op.create_check_constraint(
         None, "user_table", func.len(column("name")) > 5
     )
     context.assert_(
         "ALTER TABLE user_table ADD CONSTRAINT ck_user_table_foo "
         "CHECK (len(name) > 5)"
     )
Exemplo n.º 6
0
 def test_add_constraint_schema_hard_quoting(self):
     from sqlalchemy.sql.schema import quoted_name
     context = op_fixture("postgresql")
     op.create_check_constraint("ck_user_name_len",
                                "user_table",
                                func.len(column('name')) > 5,
                                schema=quoted_name("some.schema",
                                                   quote=True))
     context.assert_('ALTER TABLE "some.schema".user_table ADD '
                     'CONSTRAINT ck_user_name_len CHECK (len(name) > 5)')
Exemplo n.º 7
0
    def test_add_constraint_schema_hard_quoting(self):

        context = op_fixture("postgresql")
        op.create_check_constraint(
            "ck_user_name_len",
            "user_table",
            func.len(column("name")) > 5,
            schema=quoted_name("some.schema", quote=True),
        )
        context.assert_('ALTER TABLE "some.schema".user_table ADD '
                        "CONSTRAINT ck_user_name_len CHECK (len(name) > 5)")
Exemplo n.º 8
0
    def test_add_constraint_schema_hard_quoting(self):
        from sqlalchemy.sql.schema import quoted_name

        context = op_fixture("postgresql")
        op.create_check_constraint(
            "ck_user_name_len",
            "user_table",
            func.len(column("name")) > 5,
            schema=quoted_name("some.schema", quote=True),
        )
        context.assert_('ALTER TABLE "some.schema".user_table ADD ' "CONSTRAINT ck_user_name_len CHECK (len(name) > 5)")
Exemplo n.º 9
0
 def test_add_check_constraint_schema(self):
     context = op_fixture()
     op.create_check_constraint(
         "ck_user_name_len",
         "user_table",
         func.len(column('name')) > 5,
         schema='foo'
     )
     context.assert_(
         "ALTER TABLE foo.user_table ADD CONSTRAINT ck_user_name_len "
         "CHECK (len(name) > 5)"
     )