From: <fab...@us...> - 2010-07-27 18:36:15
|
Revision: 5063 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5063&view=rev Author: fabiomaulo Date: 2010-07-27 18:36:09 +0000 (Tue, 27 Jul 2010) Log Message: ----------- SchemaUpdate supporting auto-quote configuration (end Fix NH-2253) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs Modified: trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs 2010-07-27 17:52:03 UTC (rev 5062) +++ trunk/nhibernate/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs 2010-07-27 18:36:09 UTC (rev 5063) @@ -139,6 +139,13 @@ { log.Info("Running hbm2ddl schema update"); + string autoKeyWordsImport = PropertiesHelper.GetString(Environment.Hbm2ddlKeyWords, configuration.Properties, "not-defined"); + autoKeyWordsImport = autoKeyWordsImport.ToLowerInvariant(); + if (autoKeyWordsImport == Hbm2DDLKeyWords.AutoQuote) + { + SchemaMetadataUpdater.QuoteTableAndColumns(configuration); + } + DbConnection connection; IDbCommand stmt = null; Modified: trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs 2010-07-27 17:52:03 UTC (rev 5062) +++ trunk/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/AutoQuoteFixture.cs 2010-07-27 18:36:09 UTC (rev 5063) @@ -1,6 +1,10 @@ +using System.Collections.Generic; +using System.Linq; using System.Text; using NHibernate.Cfg; using NHibernate.Dialect; +using NHibernate.Mapping; +using NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest; using NHibernate.Tool.hbm2ddl; using NUnit.Framework; using SharpTestsEx; @@ -27,5 +31,32 @@ new SchemaExport(configuration).Execute(s=> script.AppendLine(s), false, false); script.ToString().Should().Contain("[Order]").And.Contain("[Select]").And.Contain("[From]").And.Contain("[And]"); } + + [Test] + public void WhenUpdateCalledExplicitlyThenTakeInAccountHbm2DdlKeyWordsSetting() + { + var configuration = TestConfigurationHelper.GetDefaultConfiguration(); + var dialect = NHibernate.Dialect.Dialect.GetDialect(configuration.Properties); + if (!(dialect is MsSql2000Dialect)) + { + Assert.Ignore(GetType() + " does not apply to " + dialect); + } + + configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote"); + configuration.AddResource("NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest.HeavyEntity.hbm.xml", + GetType().Assembly); + + var script = new StringBuilder(); + new Tool.hbm2ddl.SchemaUpdate(configuration).Execute(s => script.AppendLine(s), false); + + // With SchemaUpdate the auto-quote method should be called and the conf. should hold quoted stuff + var cm = configuration.GetClassMapping(typeof(Order)); + var culs = cm.Table.ColumnIterator.ToList(); + cm.Table.Satisfy(t=> t.IsQuoted); + culs.First(c => "From".Equals(c.Name)).Satisfy(c=> c.IsQuoted); + culs.First(c => "And".Equals(c.Name)).Satisfy(c => c.IsQuoted); + culs.First(c => "Select".Equals(c.Name)).Satisfy(c => c.IsQuoted); + culs.First(c => "Column".Equals(c.Name)).Satisfy(c => c.IsQuoted); + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |