コード例 #1
0
        public void Model_GenerateCreateTableSql_temp_table()
        {
            var temp = new SampleModel();

            temp.AddTempTableIdentity();
            var sqlBuilder = new IndentedStringBuilder();

            temp.GenerateCreateTableSql("#Temp", null, sqlBuilder, MySqlVersion.LowestSupported, true);
            var expectedSql =
                @"SET @@sql_notes = 0;
DROP TEMPORARY TABLE IF EXISTS `#Temp`;
SET @@sql_notes = 1;

CREATE TEMPORARY TABLE `#Temp` (
    `Id` INT NOT NULL COMMENT 'Id Description',
    `Name` VARCHAR(500) NULL DEFAULT('DEFAULT NAME') COMMENT 'Name Description',
    `Unique1` INT NULL COMMENT 'Unique1 Description',
    `Unique2` INT NULL COMMENT 'Unique2 Description',
    `sys_row_id` INT NOT NULL AUTO_INCREMENT,

    CONSTRAINT `PK_Temp_` UNIQUE (`Id`),
    CONSTRAINT `UQ_Temp_` UNIQUE (`Unique1`, `Unique2` DESC),
    CONSTRAINT `CK_Temp_` CHECK (`Name` IS NOT NULL),
    PRIMARY KEY (`sys_row_id` ASC)
);
";

            Assert.AreEqual(expectedSql, sqlBuilder.ToString().RemoveGuids());
        }