Merge remote-tracking branch 'origin/7.4.0' into dev-v8

Conflicts:
	build/UmbracoVersion.txt
	src/Umbraco.Core/ApplicationContext.cs
	src/Umbraco.Core/Configuration/UmbracoConfig.cs
	src/Umbraco.Core/Configuration/UmbracoVersion.cs
	src/Umbraco.Core/CoreBootManager.cs
	src/Umbraco.Core/DatabaseContext.cs
	src/Umbraco.Core/Dictionary/CultureDictionaryFactoryResolver.cs
	src/Umbraco.Core/Manifest/ManifestParser.cs
	src/Umbraco.Core/Models/DataTypeDefinition.cs
	src/Umbraco.Core/ObjectResolution/ApplicationEventsResolver.cs
	src/Umbraco.Core/Persistence/DatabaseSchemaHelper.cs
	src/Umbraco.Core/Persistence/Factories/MemberTypeFactory.cs
	src/Umbraco.Core/Persistence/Migrations/MigrationBase.cs
	src/Umbraco.Core/Persistence/Migrations/MigrationExpressionBase.cs
	src/Umbraco.Core/Persistence/Migrations/MigrationResolver.cs
	src/Umbraco.Core/Persistence/Migrations/MigrationRunner.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Alter/AlterSyntaxBuilder.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Alter/Column/AlterColumnBuilder.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Alter/Expressions/AlterColumnExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Alter/Expressions/AlterDefaultConstraintExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Alter/Expressions/AlterTableExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Alter/Table/AlterTableBuilder.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Create/Column/CreateColumnBuilder.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Create/CreateBuilder.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Create/Expressions/CreateConstraintExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Create/Expressions/CreateTableExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Create/Table/CreateTableBuilder.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/DeleteBuilder.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteColumnExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteConstraintExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteDataExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteDefaultConstraintExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteForeignKeyExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteIndexExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Delete/Expressions/DeleteTableExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/ExecuteBuilder.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/Expressions/ExecuteCodeStatementExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Execute/Expressions/ExecuteSqlStatementExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Expressions/CreateColumnExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Expressions/CreateForeignKeyExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Expressions/CreateIndexExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Insert/Expressions/InsertDataExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Insert/InsertBuilder.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Rename/Expressions/RenameColumnExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Rename/Expressions/RenameTableExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Rename/RenameBuilder.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Update/Expressions/UpdateDataExpression.cs
	src/Umbraco.Core/Persistence/Migrations/Syntax/Update/UpdateBuilder.cs
	src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSeven/AddIndexToCmsMacroTable.cs
	src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenThreeZero/MigrateAndRemoveTemplateMasterColumn.cs
	src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs
	src/Umbraco.Core/Persistence/Repositories/ContentTypeBaseRepository.cs
	src/Umbraco.Core/Persistence/Repositories/ContentTypeRepository.cs
	src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs
	src/Umbraco.Core/Persistence/Repositories/DictionaryRepository.cs
	src/Umbraco.Core/Persistence/Repositories/DomainRepository.cs
	src/Umbraco.Core/Persistence/Repositories/LanguageRepository.cs
	src/Umbraco.Core/Persistence/Repositories/MediaRepository.cs
	src/Umbraco.Core/Persistence/Repositories/MediaTypeRepository.cs
	src/Umbraco.Core/Persistence/Repositories/MemberRepository.cs
	src/Umbraco.Core/Persistence/Repositories/MemberTypeRepository.cs
	src/Umbraco.Core/Persistence/Repositories/RecycleBinRepository.cs
	src/Umbraco.Core/Persistence/Repositories/ServerRegistrationRepository.cs
	src/Umbraco.Core/Persistence/Repositories/TagRepository.cs
	src/Umbraco.Core/Persistence/Repositories/TemplateRepository.cs
	src/Umbraco.Core/Persistence/Repositories/VersionableRepositoryBase.cs
	src/Umbraco.Core/Persistence/RepositoryFactory.cs
	src/Umbraco.Core/Persistence/UmbracoDatabase.cs
	src/Umbraco.Core/PropertyEditors/IPropertyEditorValueConverter.cs
	src/Umbraco.Core/PropertyEditors/PropertyEditor.cs
	src/Umbraco.Core/PropertyEditors/PropertyEditorResolver.cs
	src/Umbraco.Core/Services/ContentService.cs
	src/Umbraco.Core/Services/ContentTypeService.cs
	src/Umbraco.Core/Services/DataTypeService.cs
	src/Umbraco.Core/Services/EntityService.cs
	src/Umbraco.Core/Services/LocalizationService.cs
	src/Umbraco.Core/Services/MacroService.cs
	src/Umbraco.Core/Services/MediaService.cs
	src/Umbraco.Core/Services/MemberGroupService.cs
	src/Umbraco.Core/Services/MemberService.cs
	src/Umbraco.Core/Services/MemberTypeService.cs
	src/Umbraco.Core/Services/PackagingService.cs
	src/Umbraco.Core/Services/ServerRegistrationService.cs
	src/Umbraco.Core/Services/ServiceContext.cs
	src/Umbraco.Core/Services/TagService.cs
	src/Umbraco.Core/Services/UserService.cs
	src/Umbraco.Core/Strings/DefaultShortStringHelper.cs
	src/Umbraco.Core/Sync/ConfigServerRegistrar.cs
	src/Umbraco.Core/Sync/DatabaseServerMessenger.cs
	src/Umbraco.Core/Umbraco.Core.csproj
	src/Umbraco.Core/UmbracoApplicationBase.cs
	src/Umbraco.Core/packages.config
	src/Umbraco.Tests/BootManagers/CoreBootManagerTests.cs
	src/Umbraco.Tests/Macros/MacroTests.cs
	src/Umbraco.Tests/Manifest/ManifestParserTests.cs
	src/Umbraco.Tests/Migrations/FindingMigrationsTest.cs
	src/Umbraco.Tests/Migrations/MigrationRunnerTests.cs
	src/Umbraco.Tests/Migrations/Stubs/FiveZeroMigration.cs
	src/Umbraco.Tests/Migrations/Stubs/FourElevenMigration.cs
	src/Umbraco.Tests/Migrations/Stubs/SixZeroMigration1.cs
	src/Umbraco.Tests/Migrations/Stubs/SixZeroMigration2.cs
	src/Umbraco.Tests/Migrations/TargetVersionSixthMigrationsTest.cs
	src/Umbraco.Tests/Migrations/Upgrades/BaseUpgradeTest.cs
	src/Umbraco.Tests/Migrations/Upgrades/SqlCeDataUpgradeTest.cs
	src/Umbraco.Tests/Mvc/UmbracoViewPageTests.cs
	src/Umbraco.Tests/Persistence/BaseTableByTableTest.cs
	src/Umbraco.Tests/Persistence/DatabaseContextTests.cs
	src/Umbraco.Tests/Persistence/Mappers/PropertyGroupMapperTest.cs
	src/Umbraco.Tests/Persistence/MySqlDatabaseCreationTest.cs
	src/Umbraco.Tests/Persistence/Querying/ContentTypeRepositorySqlClausesTest.cs
	src/Umbraco.Tests/Persistence/Querying/ContentTypeSqlMappingTests.cs
	src/Umbraco.Tests/Persistence/Repositories/ContentRepositoryTest.cs
	src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs
	src/Umbraco.Tests/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs
	src/Umbraco.Tests/Persistence/Repositories/DomainRepositoryTest.cs
	src/Umbraco.Tests/Persistence/Repositories/MediaRepositoryTest.cs
	src/Umbraco.Tests/Persistence/Repositories/MemberRepositoryTest.cs
	src/Umbraco.Tests/Persistence/Repositories/PublicAccessRepositoryTest.cs
	src/Umbraco.Tests/Persistence/Repositories/ServerRegistrationRepositoryTest.cs
	src/Umbraco.Tests/Persistence/Repositories/TagRepositoryTest.cs
	src/Umbraco.Tests/Persistence/Repositories/TemplateRepositoryTest.cs
	src/Umbraco.Tests/Persistence/SyntaxProvider/SqlCeSyntaxProviderTests.cs
	src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs
	src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs
	src/Umbraco.Tests/Services/ContentServiceTests.cs
	src/Umbraco.Tests/Services/ThreadSafetyServiceTest.cs
	src/Umbraco.Tests/Strings/DefaultShortStringHelperTests.cs
	src/Umbraco.Tests/TestHelpers/BaseDatabaseFactoryTest.cs
	src/Umbraco.Tests/TestHelpers/BaseDatabaseTest.cs
	src/Umbraco.Tests/TestHelpers/BaseUmbracoApplicationTest.cs
	src/Umbraco.Tests/Umbraco.Tests.csproj
	src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
	src/Umbraco.Web.UI/config/ClientDependency.config
	src/Umbraco.Web.UI/packages.config
	src/Umbraco.Web.UI/umbraco/controls/ContentTypeControlNew.ascx.cs
	src/Umbraco.Web.UI/umbraco/plugins/tinymce3/insertImage.aspx
	src/Umbraco.Web.UI/umbraco/settings/EditNodeTypeNew.aspx.cs
	src/Umbraco.Web/BatchedDatabaseServerMessenger.cs
	src/Umbraco.Web/Cache/CacheRefresherEventHandler.cs
	src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs
	src/Umbraco.Web/Cache/DistributedCacheExtensions.cs
	src/Umbraco.Web/Editors/AuthenticationController.cs
	src/Umbraco.Web/Editors/BackOfficeController.cs
	src/Umbraco.Web/Install/InstallSteps/DatabaseInstallStep.cs
	src/Umbraco.Web/Install/InstallSteps/DatabaseUpgradeStep.cs
	src/Umbraco.Web/Media/ThumbnailProviders/ThumbnailProvidersResolver.cs
	src/Umbraco.Web/Mvc/DefaultRenderMvcControllerResolver.cs
	src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs
	src/Umbraco.Web/PropertyEditors/FolderBrowserPropertyEditor.cs
	src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs
	src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs
	src/Umbraco.Web/Routing/NotFoundHandlerHelper.cs
	src/Umbraco.Web/Trees/MediaTreeController.cs
	src/Umbraco.Web/Trees/MemberTreeController.cs
	src/Umbraco.Web/Umbraco.Web.csproj
	src/Umbraco.Web/UmbracoApplication.cs
	src/Umbraco.Web/UmbracoModule.cs
	src/Umbraco.Web/WebBootManager.cs
	src/Umbraco.Web/packages.config
	src/Umbraco.Web/umbraco.presentation/content.cs
	src/Umbraco.Web/umbraco.presentation/keepAliveService.cs
	src/Umbraco.Web/umbraco.presentation/macro.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadDictionary.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentControl.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/controls/ContentTypeControlNew.ascx.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/controls/Images/ImageViewer.ascx.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/controls/Images/UploadMediaImage.ascx.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/imageViewer.aspx.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/rollBack.aspx.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/members/EditMemberType.aspx.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/plugins/tinymce3/insertImage.aspx
	src/Umbraco.Web/umbraco.presentation/umbraco/settings/EditNodeTypeNew.aspx.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/MediaExtensions.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/uQuery.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/users/EditUser.aspx.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/webService.asmx.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/webservices/MediaUploader.ashx.cs
	src/UmbracoExamine/UmbracoContentIndexer.cs
	src/UmbracoExamine/UmbracoMemberIndexer.cs
	src/umbraco.MacroEngines/RazorCore/UmbracoCultureDictionary.cs
	src/umbraco.MacroEngines/RazorDynamicNode/DynamicNode.cs
	src/umbraco.MacroEngines/RazorDynamicNode/ExtensionMethods.cs
	src/umbraco.MacroEngines/app.config
	src/umbraco.MacroEngines/packages.config
	src/umbraco.MacroEngines/umbraco.MacroEngines.csproj
	src/umbraco.businesslogic/UmbracoSettings.cs
	src/umbraco.cms/businesslogic/Content.cs
	src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs
	src/umbraco.cms/businesslogic/datatype/DefaultPreValueEditor.cs
	src/umbraco.cms/businesslogic/datatype/FileHandlerData.cs
	src/umbraco.cms/businesslogic/translation/Translation.cs
	src/umbraco.cms/businesslogic/web/Document.cs
	src/umbraco.cms/packages.config
	src/umbraco.editorControls/DefaultPrevalueEditor.cs
	src/umbraco.editorControls/MultiNodeTreePicker/MNTPResources.Designer.cs
	src/umbraco.editorControls/MultiNodeTreePicker/MNTPResources.resx
	src/umbraco.editorControls/MultiNodeTreePicker/MNTP_DataType.cs
	src/umbraco.editorControls/app.config
	src/umbraco.editorControls/macrocontainer/PrevalueEditor.cs
	src/umbraco.editorControls/packages.config
	src/umbraco.editorControls/textfieldmultiple/textfieldMultipleDataType.cs
	src/umbraco.editorControls/umbraco.editorControls.csproj
	src/umbraco.editorControls/uploadfield/uploadField.cs
	src/umbraco.editorControls/userControlWrapper/usercontrolPrevalueEditor.cs
	src/umbraco.providers/app.config
This commit is contained in:
Shannon
2015-12-18 11:23:58 +01:00
1831 changed files with 59279 additions and 54016 deletions

View File

@@ -54,6 +54,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax
string DeleteConstraint { get; }
string CreateForeignKeyConstraint { get; }
string DeleteDefaultConstraint { get; }
string FormatDateTime(DateTime date, bool includeTime = true);
string Format(TableDefinition table);
string Format(IEnumerable<ColumnDefinition> columns);
List<string> Format(IEnumerable<IndexDefinition> indexes);

View File

@@ -10,6 +10,19 @@ namespace Umbraco.Core.Persistence.SqlSyntax
public abstract class MicrosoftSqlSyntaxProviderBase<TSyntax> : SqlSyntaxProviderBase<TSyntax>
where TSyntax : ISqlSyntaxProvider
{
protected MicrosoftSqlSyntaxProviderBase()
{
AutoIncrementDefinition = "IDENTITY(1,1)";
GuidColumnDefinition = "UniqueIdentifier";
RealColumnDefinition = "FLOAT";
BoolColumnDefinition = "BIT";
DecimalColumnDefinition = "DECIMAL(38,6)";
TimeColumnDefinition = "TIME"; //SQLSERVER 2008+
BlobColumnDefinition = "VARBINARY(MAX)";
InitColumnTypeMap();
}
public override string RenameTable { get { return "sp_rename '{0}', '{1}'"; } }
public override string AddColumn { get { return "ALTER TABLE {0} ADD {1}"; } }

View File

@@ -18,10 +18,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax
public MySqlSyntaxProvider(ILogger logger)
{
_logger = logger;
DefaultStringLength = 255;
StringLengthColumnDefinitionFormat = StringLengthUnicodeColumnDefinitionFormat;
StringColumnDefinition = string.Format(StringLengthColumnDefinitionFormat, DefaultStringLength);
AutoIncrementDefinition = "AUTO_INCREMENT";
IntColumnDefinition = "int(11)";
BoolColumnDefinition = "tinyint(1)";
@@ -29,10 +26,8 @@ namespace Umbraco.Core.Persistence.SqlSyntax
TimeColumnDefinition = "time";
DecimalColumnDefinition = "decimal(38,6)";
GuidColumnDefinition = "char(36)";
InitColumnTypeMap();
DefaultValueFormat = "DEFAULT '{0}'";
DefaultValueFormat = "DEFAULT {0}";
}
public override IEnumerable<string> GetTablesInSchema(Database db)
@@ -191,6 +186,21 @@ ORDER BY TABLE_NAME, INDEX_NAME",
return false;
}
/// <summary>
/// This is used ONLY if we need to format datetime without using SQL parameters (i.e. during migrations)
/// </summary>
/// <param name="date"></param>
/// <param name="includeTime"></param>
/// <returns></returns>
/// <remarks>
/// MySQL has a DateTime standard that is unambiguous and works on all servers:
/// YYYYMMDDHHMMSS
/// </remarks>
public override string FormatDateTime(DateTime date, bool includeTime = true)
{
return includeTime ? date.ToString("yyyyMMddHHmmss") : date.ToString("yyyyMMdd");
}
public override string GetQuotedTableName(string tableName)
{
return string.Format("`{0}`", tableName);
@@ -285,6 +295,10 @@ ORDER BY TABLE_NAME, INDEX_NAME",
if (column.DefaultValue == null)
return string.Empty;
//hack - probably not needed with latest changes
if (column.DefaultValue.ToString().ToLower().Equals("getdate()".ToLower()))
column.DefaultValue = SystemMethods.CurrentDateTime;
// see if this is for a system method
if (column.DefaultValue is SystemMethods)
{
@@ -295,10 +309,8 @@ ORDER BY TABLE_NAME, INDEX_NAME",
return string.Format(DefaultValueFormat, method);
}
if (column.DefaultValue.ToString().ToLower().Equals("getdate()".ToLower()))
return "DEFAULT CURRENT_TIMESTAMP";
return string.Format(DefaultValueFormat, column.DefaultValue);
//needs quote
return string.Format(DefaultValueFormat, string.Format("'{0}'", column.DefaultValue));
}
protected override string FormatPrimaryKey(ColumnDefinition column)
@@ -311,13 +323,14 @@ ORDER BY TABLE_NAME, INDEX_NAME",
switch (systemMethod)
{
case SystemMethods.NewGuid:
return "NEWID()";
case SystemMethods.NewSequentialId:
return "NEWSEQUENTIALID()";
return null; // NOT SUPPORTED!
//return "NEWID()";
case SystemMethods.CurrentDateTime:
return "GETDATE()";
case SystemMethods.CurrentUTCDateTime:
return "GETUTCDATE()";
return "CURRENT_TIMESTAMP";
//case SystemMethods.NewSequentialId:
// return "NEWSEQUENTIALID()";
//case SystemMethods.CurrentUTCDateTime:
// return "GETUTCDATE()";
}
return null;

View File

@@ -15,19 +15,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax
{
public SqlCeSyntaxProvider()
{
StringLengthColumnDefinitionFormat = StringLengthUnicodeColumnDefinitionFormat;
StringColumnDefinition = string.Format(StringLengthColumnDefinitionFormat, DefaultStringLength);
AutoIncrementDefinition = "IDENTITY(1,1)";
StringColumnDefinition = "NVARCHAR(255)";
GuidColumnDefinition = "UniqueIdentifier";
RealColumnDefinition = "FLOAT";
BoolColumnDefinition = "BIT";
DecimalColumnDefinition = "DECIMAL(38,6)";
TimeColumnDefinition = "TIME"; //SQLSERVER 2008+
BlobColumnDefinition = "VARBINARY(MAX)";
InitColumnTypeMap();
}
public override bool SupportsClustered()
@@ -197,13 +185,13 @@ ORDER BY TABLE_NAME, INDEX_NAME");
switch (systemMethod)
{
case SystemMethods.NewGuid:
return "NEWID()";
case SystemMethods.NewSequentialId:
return "NEWSEQUENTIALID()";
return "NEWID()";
case SystemMethods.CurrentDateTime:
return "GETDATE()";
case SystemMethods.CurrentUTCDateTime:
return "GETUTCDATE()";
//case SystemMethods.NewSequentialId:
// return "NEWSEQUENTIALID()";
//case SystemMethods.CurrentUTCDateTime:
// return "GETUTCDATE()";
}
return null;

View File

@@ -13,19 +13,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax
{
public SqlServerSyntaxProvider()
{
StringLengthColumnDefinitionFormat = StringLengthUnicodeColumnDefinitionFormat;
StringColumnDefinition = string.Format(StringLengthColumnDefinitionFormat, DefaultStringLength);
AutoIncrementDefinition = "IDENTITY(1,1)";
StringColumnDefinition = "VARCHAR(8000)";
GuidColumnDefinition = "UniqueIdentifier";
RealColumnDefinition = "FLOAT";
BoolColumnDefinition = "BIT";
DecimalColumnDefinition = "DECIMAL(38,6)";
TimeColumnDefinition = "TIME"; //SQLSERVER 2008+
BlobColumnDefinition = "VARBINARY(MAX)";
InitColumnTypeMap();
}
/// <summary>
@@ -126,13 +114,13 @@ order by T.name, I.name");
switch (systemMethod)
{
case SystemMethods.NewGuid:
return "NEWID()";
case SystemMethods.NewSequentialId:
return "NEWSEQUENTIALID()";
return "NEWID()";
case SystemMethods.CurrentDateTime:
return "GETDATE()";
case SystemMethods.CurrentUTCDateTime:
return "GETUTCDATE()";
//case SystemMethods.NewSequentialId:
// return "NEWSEQUENTIALID()";
//case SystemMethods.CurrentUTCDateTime:
// return "GETUTCDATE()";
}
return null;

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Text;
using Umbraco.Core.Persistence.DatabaseAnnotations;
@@ -31,6 +32,13 @@ namespace Umbraco.Core.Persistence.SqlSyntax
FormatPrimaryKey,
FormatIdentity
};
//defaults for all providers
StringLengthColumnDefinitionFormat = StringLengthUnicodeColumnDefinitionFormat;
StringColumnDefinition = string.Format(StringLengthColumnDefinitionFormat, DefaultStringLength);
DecimalColumnDefinition = string.Format(DecimalColumnDefinitionFormat, DefaultDecimalPrecision, DefaultDecimalScale);
InitColumnTypeMap();
}
public string GetWildcardPlaceholder()
@@ -40,9 +48,12 @@ namespace Umbraco.Core.Persistence.SqlSyntax
public string StringLengthNonUnicodeColumnDefinitionFormat = "VARCHAR({0})";
public string StringLengthUnicodeColumnDefinitionFormat = "NVARCHAR({0})";
public string DecimalColumnDefinitionFormat = "DECIMAL({0},{1})";
public string DefaultValueFormat = "DEFAULT ({0})";
public int DefaultStringLength = 255;
public int DefaultDecimalPrecision = 20;
public int DefaultDecimalScale = 9;
//Set by Constructor
public string StringColumnDefinition;
@@ -54,7 +65,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax
public string GuidColumnDefinition = "GUID";
public string BoolColumnDefinition = "BOOL";
public string RealColumnDefinition = "DOUBLE";
public string DecimalColumnDefinition = "DECIMAL";
public string DecimalColumnDefinition;
public string BlobColumnDefinition = "BLOB";
public string DateTimeColumnDefinition = "DATETIME";
public string TimeColumnDefinition = "DATETIME";
@@ -251,6 +262,23 @@ namespace Umbraco.Core.Persistence.SqlSyntax
return true;
}
/// <summary>
/// This is used ONLY if we need to format datetime without using SQL parameters (i.e. during migrations)
/// </summary>
/// <param name="date"></param>
/// <param name="includeTime"></param>
/// <returns></returns>
/// <remarks>
/// MSSQL has a DateTime standard that is unambiguous and works on all servers:
/// YYYYMMDD HH:mm:ss
/// </remarks>
public virtual string FormatDateTime(DateTime date, bool includeTime = true)
{
// need CultureInfo.InvariantCulture because ":" here is the "time separator" and
// may be converted to something else in different cultures (eg "." in DK).
return date.ToString(includeTime ? "yyyyMMdd HH:mm:ss" : "yyyyMMdd", CultureInfo.InvariantCulture);
}
public virtual string Format(TableDefinition table)
{
var statement = string.Format(CreateTable, GetQuotedTableName(table.Name), Format(table.Columns));
@@ -413,6 +441,13 @@ namespace Umbraco.Core.Persistence.SqlSyntax
return string.Format(StringLengthColumnDefinitionFormat, valueOrDefault);
}
if (type == typeof(decimal))
{
var precision = column.Size != default(int) ? column.Size : DefaultDecimalPrecision;
var scale = column.Precision != default(int) ? column.Precision : DefaultDecimalScale;
return string.Format(DecimalColumnDefinitionFormat, precision, scale);
}
string definition = DbTypeMap.ColumnTypeMap.First(x => x.Key == type).Value;
string dbTypeDefinition = column.Size != default(int)
? string.Format("{0}({1})", definition, column.Size)
@@ -442,9 +477,9 @@ namespace Umbraco.Core.Persistence.SqlSyntax
if (column.DefaultValue == null)
return string.Empty;
// TODO: Actually use the SystemMethods on the DTO. For now I've put a hack in to catch getdate(), not using the others at the moment
//hack - probably not needed with latest changes
if (column.DefaultValue.ToString().ToLower().Equals("getdate()".ToLower()))
return string.Format(DefaultValueFormat, column.DefaultValue);
column.DefaultValue = SystemMethods.CurrentDateTime;
// see if this is for a system method
if (column.DefaultValue is SystemMethods)