Ejemplo n.º 1
0
        public void GetIfExistsDropConstraintTest_with_quoted_catalog_quoted_schema_quoted_table()
        {
            var          dialect  = new MsSql2005Dialect();
            const string expected = "if exists (select 1 from [Catalog].sys.objects" +
                                    " where object_id = OBJECT_ID(N'[Catalog].[Schema].[Bar]')" +
                                    " and parent_object_id = OBJECT_ID(N'[Catalog].[Schema].[Foo]'))";
            var ifExistsDropConstraint = dialect.GetIfExistsDropConstraint("[Catalog]", "[Schema]", "[Foo]", "Bar");

            Assert.That(ifExistsDropConstraint, Is.EqualTo(expected));
        }
Ejemplo n.º 2
0
        public void GetIfExistsDropConstraintTest_with_quoted_schema()
        {
            var          dialect  = new MsSql2005Dialect();
            const string expected = "if exists (select 1 from sys.objects" +
                                    " where object_id = OBJECT_ID(N'[Other].[Bar]')" +
                                    " and parent_object_id = OBJECT_ID(N'[Other].Foo'))";
            var ifExistsDropConstraint = dialect.GetIfExistsDropConstraint(null, "[Other]", "Foo", "Bar");

            Assert.That(ifExistsDropConstraint, Is.EqualTo(expected));
        }
Ejemplo n.º 3
0
        public void GetIfExistsDropConstraintTest_with_catalog_with_schema()
        {
            var          dialect  = new MsSql2005Dialect();
            const string expected = "if exists (select 1 from Catalog.sys.objects" +
                                    " where object_id = OBJECT_ID(N'Catalog.Schema.[Bar]')" +
                                    " and parent_object_id = OBJECT_ID(N'Catalog.Schema.Foo'))";
            var ifExistsDropConstraint = dialect.GetIfExistsDropConstraint("Catalog", "Schema", "Foo", "Bar");

            Assert.That(ifExistsDropConstraint, Is.EqualTo(expected));
        }
Ejemplo n.º 4
0
        public void GetIfExistsDropConstraintTest_without_schema()
        {
            MsSql2005Dialect dialect  = new MsSql2005Dialect();
            Table            foo      = new Table("Foo");
            string           expected = "if exists (select 1 from sys.objects" +
                                        " where object_id = OBJECT_ID(N'[Bar]')" +
                                        " AND parent_object_id = OBJECT_ID('Foo'))";
            string ifExistsDropConstraint = dialect.GetIfExistsDropConstraint(foo, "Bar");

            System.Console.WriteLine(ifExistsDropConstraint);
            Assert.AreEqual(expected, ifExistsDropConstraint);
        }