U4-8017 - fix issues with MySql InitColumnTypeMap
This commit is contained in:
@@ -28,6 +28,8 @@ namespace Umbraco.Core.Persistence.SqlSyntax
|
|||||||
GuidColumnDefinition = "char(36)";
|
GuidColumnDefinition = "char(36)";
|
||||||
|
|
||||||
DefaultValueFormat = "DEFAULT {0}";
|
DefaultValueFormat = "DEFAULT {0}";
|
||||||
|
|
||||||
|
InitColumnTypeMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<string> GetTablesInSchema(Database db)
|
public override IEnumerable<string> GetTablesInSchema(Database db)
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Umbraco.Core.Logging;
|
using Umbraco.Core.Logging;
|
||||||
using Umbraco.Core.Models.Rdbms;
|
using Umbraco.Core.Models.Rdbms;
|
||||||
|
using Umbraco.Core.Persistence;
|
||||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||||
|
using Umbraco.Core.Persistence.Migrations;
|
||||||
using Umbraco.Core.Persistence.SqlSyntax;
|
using Umbraco.Core.Persistence.SqlSyntax;
|
||||||
|
|
||||||
namespace Umbraco.Tests.Persistence.SyntaxProvider
|
namespace Umbraco.Tests.Persistence.SyntaxProvider
|
||||||
{
|
{
|
||||||
[NUnit.Framework.Ignore("This doesn't actually test anything")]
|
//[NUnit.Framework.Ignore("This doesn't actually test anything")]
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class MySqlSyntaxProviderTests
|
public class MySqlSyntaxProviderTests
|
||||||
{
|
{
|
||||||
@@ -20,6 +22,7 @@ namespace Umbraco.Tests.Persistence.SyntaxProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
[NUnit.Framework.Ignore]
|
||||||
public void Can_Generate_Create_Table_Statement()
|
public void Can_Generate_Create_Table_Statement()
|
||||||
{
|
{
|
||||||
var type = typeof(TagRelationshipDto);
|
var type = typeof(TagRelationshipDto);
|
||||||
@@ -48,5 +51,40 @@ namespace Umbraco.Tests.Persistence.SyntaxProvider
|
|||||||
{
|
{
|
||||||
SqlSyntaxContext.SqlSyntaxProvider = null;
|
SqlSyntaxContext.SqlSyntaxProvider = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void U4_8017()
|
||||||
|
{
|
||||||
|
var logger = Mock.Of<ILogger>();
|
||||||
|
var migration = new TestMigration(SqlSyntaxContext.SqlSyntaxProvider, logger);
|
||||||
|
var context = new MigrationContext(DatabaseProviders.MySql, null, logger);
|
||||||
|
migration.Context = context;
|
||||||
|
migration.Up();
|
||||||
|
var x = context.Expressions;
|
||||||
|
Assert.AreEqual(1, x.Count);
|
||||||
|
var e = x.First().ToString();
|
||||||
|
|
||||||
|
// SQLCE provider *does* use UniqueIdentifier
|
||||||
|
// MySql using GUID...? because InitColumnTypeMap() missing in provider, fixed
|
||||||
|
|
||||||
|
Assert.AreEqual("ALTER TABLE `cmsPropertyTypeGroup` ADD COLUMN `uniqueID` char(36) NOT NULL", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Migration("1.0.0", 0, "Test")]
|
||||||
|
private class TestMigration : MigrationBase
|
||||||
|
{
|
||||||
|
public TestMigration(ISqlSyntaxProvider sqlSyntax, ILogger logger) : base(sqlSyntax, logger)
|
||||||
|
{}
|
||||||
|
|
||||||
|
public override void Up()
|
||||||
|
{
|
||||||
|
Create.Column("uniqueID").OnTable("cmsPropertyTypeGroup").AsGuid().NotNullable().WithDefault(SystemMethods.NewGuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Down()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user