public override void CanAlterSchema()
        {
            var expression = GeneratorTestHelper.GetAlterSchemaExpression();

            var result = Generator.Generate(expression);

            result.ShouldBe("ALTER TABLE \"TestSchema1\".\"TestTable\" SET SCHEMA \"TestSchema2\";");
        }
        public void CanUpdateData()
        {
            var expression = GeneratorTestHelper.GetUpdateDataExpression();

            var sql = generator.Generate(expression);

            sql.ShouldBe("UPDATE \"public\".\"TestTable1\" SET \"Name\" = 'Just''in', \"Age\" = 25 WHERE \"Id\" = 9 AND \"Homepage\" IS NULL");
        }
        public override void CanCreateSequenceWithCustomSchema()
        {
            var expression = GeneratorTestHelper.GetCreateSequenceExpression();

            expression.Sequence.SchemaName = "TestSchema";

            var result = Generator.Generate(expression);

            result.ShouldBe("CREATE SEQUENCE \"TestSchema\".\"Sequence\" INCREMENT 2 MINVALUE 0 MAXVALUE 100 START WITH 2 CACHE 10 CYCLE");
        }
        public override void CanCreateIndexWithCustomSchema()
        {
            var expression = GeneratorTestHelper.GetCreateIndexExpression();

            expression.Index.SchemaName = "TestSchema";

            var result = Generator.Generate(expression);

            result.ShouldBe("CREATE INDEX \"TestIndex\" ON \"TestSchema\".\"TestTable1\" (\"TestColumn1\" ASC);");
        }
Exemple #5
0
        public void CanCreateTableWithBlobColumnWithObjectType()
        {
            var expression = GeneratorTestHelper.GetCreateTableExpression();

            expression.Columns[0].Type = DbType.Object;

            var result = Generator.Generate(expression);

            result.ShouldBe("CREATE TABLE \"public\".\"TestTable1\" (\"TestColumn1\" json NOT NULL, \"TestColumn2\" integer NOT NULL);");
        }
        public override void CanDeleteDataForAllRowsWithCustomSchema()
        {
            var expression = GeneratorTestHelper.GetDeleteDataAllRowsExpression();

            expression.SchemaName = "TestSchema";

            var result = Generator.Generate(expression);

            result.ShouldBe("DELETE FROM \"TestSchema\".\"TestTable1\";");
        }
Exemple #7
0
        public void CanCreateTableWithDateTimeOffsetColumn()
        {
            var tableName  = "TestTable1";
            var expression = new CreateTableExpression {
                TableName = tableName
            };

            expression.Columns.Add(new ColumnDefinition {
                TableName = tableName, Name = "TestColumn1", Type = DbType.DateTimeOffset
            });
            expression.Columns.Add(new ColumnDefinition {
                TableName = tableName, Name = "TestColumn2", Type = DbType.DateTime2
            });
            expression.Columns.Add(new ColumnDefinition {
                TableName = tableName, Name = "TestColumn3", Type = DbType.Date
            });
            expression.Columns.Add(new ColumnDefinition {
                TableName = tableName, Name = "TestColumn4", Type = DbType.Time
            });

            var result = Generator.Generate(expression);

            result.ShouldBe(string.Format("CREATE TABLE \"public\".\"{0}\" (\"TestColumn1\" timestamptz NOT NULL, \"TestColumn2\" timestamp NOT NULL, \"TestColumn3\" date NOT NULL, \"TestColumn4\" time NOT NULL);", tableName));
        }
        public override void CanAlterColumnWithCustomSchema()
        {
            var expression = GeneratorTestHelper.GetAlterColumnExpression();

            expression.Column.IsNullable = null;
            expression.SchemaName        = "TestSchema";

            var result = Generator.Generate(expression);

            result.ShouldBe("ALTER TABLE \"TestSchema\".\"TestTable1\" ALTER \"TestColumn1\" TYPE varchar(20);");
        }
        public override void CanCreateForeignKeyWithCustomSchema()
        {
            var expression = GeneratorTestHelper.GetCreateForeignKeyExpression();

            expression.ForeignKey.ForeignTableSchema = "TestSchema";
            expression.ForeignKey.PrimaryTableSchema = "TestSchema";

            var result = Generator.Generate(expression);

            result.ShouldBe("ALTER TABLE \"TestSchema\".\"TestTable1\" ADD CONSTRAINT \"FK_TestTable1_TestColumn1_TestTable2_TestColumn2\" FOREIGN KEY (\"TestColumn1\") REFERENCES \"TestSchema\".\"TestTable2\" (\"TestColumn2\");");
        }
Exemple #10
0
        public override void CanCreateNullableColumnWithCustomDomainTypeAndCustomSchema()
        {
            var expression = GeneratorTestHelper.GetCreateColumnExpressionWithNullableCustomType();

            expression.SchemaName = "TestSchema";

            var result = Generator.Generate(expression);

            result.ShouldBe("ALTER TABLE \"TestSchema\".\"TestTable1\" ADD \"TestColumn1\" MyDomainType NULL;");
        }
        public override void CanCreateTableWithCustomColumnTypeWithCustomSchema()
        {
            var expression = GeneratorTestHelper.GetCreateTableExpression();

            expression.Columns[0].IsPrimaryKey = true;
            expression.Columns[1].Type         = null;
            expression.Columns[1].CustomType   = "json";
            expression.SchemaName = "TestSchema";

            var result = Generator.Generate(expression);

            result.ShouldBe("CREATE TABLE \"TestSchema\".\"TestTable1\" (\"TestColumn1\" text NOT NULL, \"TestColumn2\" json NOT NULL, PRIMARY KEY (\"TestColumn1\"));");
        }
        public void CanCreateSchema()
        {
            var expression = new CreateSchemaExpression {
                SchemaName = "Schema1"
            };
            var sql = generator.Generate(expression);

            sql.ShouldBe("CREATE SCHEMA \"Schema1\"");
        }
        public void CanCreateAutoIncrementColumnForInt64()
        {
            var expression = GeneratorTestHelper.GetCreateTableWithAutoIncrementExpression();

            expression.Columns[0].Type = DbType.Int64;

            var result = Generator.Generate(expression);

            result.ShouldBe("CREATE TABLE \"public\".\"TestTable1\" (\"TestColumn1\" bigserial NOT NULL, \"TestColumn2\" integer NOT NULL)");
        }