Merge pull request #1139 from umbraco/temp-U4-8017

U4-8017 - fix issues with MySql InitColumnTypeMap
This commit is contained in:
Sebastiaan Janssen
2016-02-22 19:05:41 +01:00
2 changed files with 44 additions and 3 deletions

View File

@@ -28,6 +28,8 @@ namespace Umbraco.Core.Persistence.SqlSyntax
GuidColumnDefinition = "char(36)";
DefaultValueFormat = "DEFAULT {0}";
InitColumnTypeMap();
}
public override IEnumerable<string> GetTablesInSchema(Database db)

View File

@@ -1,17 +1,20 @@
using System;
using System.Linq;
using Moq;
using NUnit.Framework;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
using Umbraco.Core.Persistence.Migrations;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Persistence.SyntaxProvider
{
[NUnit.Framework.Ignore("This doesn't actually test anything")]
//[NUnit.Framework.Ignore("This doesn't actually test anything")]
[TestFixture]
public class MySqlSyntaxProviderTests
public class MySqlSyntaxProviderTests : BaseUsingSqlCeSyntax
{
[SetUp]
public void SetUp()
@@ -20,6 +23,7 @@ namespace Umbraco.Tests.Persistence.SyntaxProvider
}
[Test]
[NUnit.Framework.Ignore]
public void Can_Generate_Create_Table_Statement()
{
var type = typeof(TagRelationshipDto);
@@ -48,5 +52,40 @@ namespace Umbraco.Tests.Persistence.SyntaxProvider
{
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();
}
}
}
}