From 1bc19bdff0e5079fde6df5944cf11cef57abcc61 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Fri, 16 Jul 2010 13:51:07 -0700 Subject: [PATCH] Simplified syntax for clob fields --HG-- branch : dev --- .../DataMigration/SchemaCommandGeneratorTests.cs | 2 +- .../Core/Common/DataMigrations/CommonDataMigration.cs | 2 +- .../DataMigrations/CommentsDataMigration.cs | 2 +- .../Services/ScaffoldingCommandInterpreter.cs | 7 ++++++- src/Orchard/Data/Migration/Schema/AlterColumnCommand.cs | 9 +++++++++ src/Orchard/Data/Migration/Schema/ColumnCommand.cs | 3 +++ src/Orchard/Data/Migration/Schema/CreateColumnCommand.cs | 4 ++++ 7 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Orchard.Tests/DataMigration/SchemaCommandGeneratorTests.cs b/src/Orchard.Tests/DataMigration/SchemaCommandGeneratorTests.cs index 4f37baa5c..2f833590c 100644 --- a/src/Orchard.Tests/DataMigration/SchemaCommandGeneratorTests.cs +++ b/src/Orchard.Tests/DataMigration/SchemaCommandGeneratorTests.cs @@ -165,7 +165,7 @@ features: interpreter.Visit(bodyRecord); Assert.That(sw.ToString().Contains("SchemaBuilder.CreateTable(\"TEST_BodyRecord")); Assert.That(sw.ToString().Contains(".ContentPartVersionRecord()")); - Assert.That(sw.ToString().Contains(".Column(\"Text\", DbType.String, column => column.WithLength(10000))")); + Assert.That(sw.ToString().Contains(".Column(\"Text\", DbType.String, column => column.Unlimited())")); Assert.That(sw.ToString().Contains(".Column(\"Format\", DbType.String, column => column.WithLength(42))")); Assert.That(!sw.ToString().Contains("ContentItemRecord_id")); } diff --git a/src/Orchard.Web/Core/Common/DataMigrations/CommonDataMigration.cs b/src/Orchard.Web/Core/Common/DataMigrations/CommonDataMigration.cs index 259d7f5aa..beebe7f35 100644 --- a/src/Orchard.Web/Core/Common/DataMigrations/CommonDataMigration.cs +++ b/src/Orchard.Web/Core/Common/DataMigrations/CommonDataMigration.cs @@ -7,7 +7,7 @@ namespace Orchard.Core.Common.DataMigrations { //CREATE TABLE Common_BodyRecord (Id INTEGER not null, Text TEXT, Format TEXT, ContentItemRecord_id INTEGER, primary key (Id)); SchemaBuilder.CreateTable("BodyRecord", table => table .ContentPartVersionRecord() - .Column("Text", column => column.WithLength(10000)) + .Column("Text", column => column.Unlimited()) .Column("Format") ); diff --git a/src/Orchard.Web/Modules/Orchard.Comments/DataMigrations/CommentsDataMigration.cs b/src/Orchard.Web/Modules/Orchard.Comments/DataMigrations/CommentsDataMigration.cs index 5bdcdb924..e913042b7 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/DataMigrations/CommentsDataMigration.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/DataMigrations/CommentsDataMigration.cs @@ -20,7 +20,7 @@ namespace Orchard.Comments.DataMigrations { .Column("Email") .Column("Status") .Column("CommentDateUtc") - .Column("CommentText", column => column.WithLength(10000)) + .Column("CommentText", column => column.Unlimited()) .Column("CommentedOn") .Column("CommentedOnContainer") ); diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Services/ScaffoldingCommandInterpreter.cs b/src/Orchard.Web/Modules/Orchard.DevTools/Services/ScaffoldingCommandInterpreter.cs index 361ecf249..9bb513cda 100644 --- a/src/Orchard.Web/Modules/Orchard.DevTools/Services/ScaffoldingCommandInterpreter.cs +++ b/src/Orchard.Web/Modules/Orchard.DevTools/Services/ScaffoldingCommandInterpreter.cs @@ -67,7 +67,12 @@ namespace Orchard.DevTools.Services { } if ( createColumn.Length.HasValue ) { - options.Add(string.Format("WithLength({0})", createColumn.Length )); + if ( createColumn.Length == 10000 ) { + options.Add("Unlimited()"); + } + else { + options.Add(string.Format("WithLength({0})", createColumn.Length)); + } } if ( createColumn.Precision > 0 ) { diff --git a/src/Orchard/Data/Migration/Schema/AlterColumnCommand.cs b/src/Orchard/Data/Migration/Schema/AlterColumnCommand.cs index 711a309a6..687f6d1fd 100644 --- a/src/Orchard/Data/Migration/Schema/AlterColumnCommand.cs +++ b/src/Orchard/Data/Migration/Schema/AlterColumnCommand.cs @@ -23,5 +23,14 @@ namespace Orchard.Data.Migration.Schema { return this; } + public new AlterColumnCommand WithLength(int? length) { + base.WithLength(length); + return this; + } + + public new AlterColumnCommand Unlimited() { + return WithLength(10000); + } + } } diff --git a/src/Orchard/Data/Migration/Schema/ColumnCommand.cs b/src/Orchard/Data/Migration/Schema/ColumnCommand.cs index a5fc59f13..d172229e0 100644 --- a/src/Orchard/Data/Migration/Schema/ColumnCommand.cs +++ b/src/Orchard/Data/Migration/Schema/ColumnCommand.cs @@ -37,5 +37,8 @@ namespace Orchard.Data.Migration.Schema { return this; } + public ColumnCommand Unlimited() { + return WithLength(10000); + } } } diff --git a/src/Orchard/Data/Migration/Schema/CreateColumnCommand.cs b/src/Orchard/Data/Migration/Schema/CreateColumnCommand.cs index 25d06222c..b672312a1 100644 --- a/src/Orchard/Data/Migration/Schema/CreateColumnCommand.cs +++ b/src/Orchard/Data/Migration/Schema/CreateColumnCommand.cs @@ -64,6 +64,10 @@ namespace Orchard.Data.Migration.Schema { return this; } + public new CreateColumnCommand Unlimited() { + return WithLength(10000); + } + public new CreateColumnCommand WithType(DbType dbType) { base.WithType(dbType); return this;