1+ using System ;
12using System . Collections . Generic ;
23using System . Linq ;
34using NHibernate . Cfg ;
45using NHibernate . Engine ;
56using NHibernate . Mapping ;
67using NHibernate . Tool . hbm2ddl ;
78using NUnit . Framework ;
9+ using Environment = NHibernate . Cfg . Environment ;
810
911namespace NHibernate . Test . Tools . hbm2ddl . SchemaMetadataUpdaterTest
1012{
@@ -23,8 +25,8 @@ public void CanRetrieveReservedWords()
2325 var metaData = dialect . GetDataBaseSchema ( connectionHelper . Connection ) ;
2426 var reserved = metaData . GetReservedWords ( ) ;
2527 Assert . That ( reserved , Is . Not . Empty ) ;
26- Assert . That ( reserved , Has . Member ( "SELECT" ) ) ;
27- Assert . That ( reserved , Has . Member ( "FROM" ) ) ;
28+ Assert . That ( reserved , Has . Member ( "SELECT" ) . IgnoreCase ) ;
29+ Assert . That ( reserved , Has . Member ( "FROM" ) . IgnoreCase ) ;
2830 }
2931 finally
3032 {
@@ -35,7 +37,7 @@ public void CanRetrieveReservedWords()
3537 [ Test ]
3638 public void UpdateReservedWordsInDialect ( )
3739 {
38- var reservedDb = new HashSet < string > ( ) ;
40+ var reservedDb = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
3941 var configuration = TestConfigurationHelper . GetDefaultConfiguration ( ) ;
4042 var dialect = Dialect . Dialect . GetDialect ( configuration . Properties ) ;
4143 var connectionHelper = new ManagedProviderConnectionHelper ( configuration . Properties ) ;
@@ -55,7 +57,7 @@ public void UpdateReservedWordsInDialect()
5557
5658 var sf = ( ISessionFactoryImplementor ) configuration . BuildSessionFactory ( ) ;
5759 SchemaMetadataUpdater . Update ( sf ) ;
58- var match = reservedDb . Intersect ( sf . Dialect . Keywords ) ;
60+ var match = reservedDb . Intersect ( sf . Dialect . Keywords , StringComparer . OrdinalIgnoreCase ) ;
5961 Assert . That ( match , Is . EquivalentTo ( reservedDb ) ) ;
6062 }
6163
@@ -66,14 +68,19 @@ public void ExplicitAutoQuote()
6668 configuration . AddResource ( "NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest.HeavyEntity.hbm.xml" ,
6769 GetType ( ) . Assembly ) ;
6870
69- SchemaMetadataUpdater . QuoteTableAndColumns ( configuration ) ;
71+ var dialect = Dialect . Dialect . GetDialect ( configuration . GetDerivedProperties ( ) ) ;
72+ dialect . Keywords . Add ( "Abracadabra" ) ;
73+
74+ SchemaMetadataUpdater . Update ( configuration , dialect ) ;
75+ SchemaMetadataUpdater . QuoteTableAndColumns ( configuration , dialect ) ;
7076
7177 var cm = configuration . GetClassMapping ( typeof ( Order ) ) ;
7278 Assert . That ( cm . Table . IsQuoted ) ;
7379 var culs = new List < Column > ( cm . Table . ColumnIterator ) ;
7480 Assert . That ( GetColumnByName ( culs , "From" ) . IsQuoted ) ;
7581 Assert . That ( GetColumnByName ( culs , "And" ) . IsQuoted ) ;
7682 Assert . That ( GetColumnByName ( culs , "Select" ) . IsQuoted ) ;
83+ Assert . That ( GetColumnByName ( culs , "Abracadabra" ) . IsQuoted ) ;
7784 Assert . That ( ! GetColumnByName ( culs , "Name" ) . IsQuoted ) ;
7885 }
7986
@@ -97,7 +104,7 @@ public void AutoQuoteTableAndColumnsAtStratup()
97104 [ Test ]
98105 public void AutoQuoteTableAndColumnsAtStratupIncludeKeyWordsImport ( )
99106 {
100- var reservedDb = new HashSet < string > ( ) ;
107+ var reservedDb = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
101108 var configuration = TestConfigurationHelper . GetDefaultConfiguration ( ) ;
102109 var dialect = Dialect . Dialect . GetDialect ( configuration . Properties ) ;
103110 var connectionHelper = new ManagedProviderConnectionHelper ( configuration . Properties ) ;
@@ -119,8 +126,8 @@ public void AutoQuoteTableAndColumnsAtStratupIncludeKeyWordsImport()
119126 configuration . AddResource ( "NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest.HeavyEntity.hbm.xml" ,
120127 GetType ( ) . Assembly ) ;
121128 var sf = ( ISessionFactoryImplementor ) configuration . BuildSessionFactory ( ) ;
122- var match = reservedDb . Intersect ( sf . Dialect . Keywords ) ;
123- Assert . That ( match , Is . EquivalentTo ( reservedDb ) ) ;
129+ var match = reservedDb . Intersect ( sf . Dialect . Keywords , StringComparer . OrdinalIgnoreCase ) ;
130+ Assert . That ( match , Is . EquivalentTo ( reservedDb ) . IgnoreCase ) ;
124131 }
125132
126133 private static Column GetColumnByName ( IEnumerable < Column > columns , string colName )
@@ -167,14 +174,19 @@ public void WhenConfiguredOnlyExplicitAutoQuote()
167174 configuration . AddResource ( "NHibernate.Test.Tools.hbm2ddl.SchemaMetadataUpdaterTest.HeavyEntity.hbm.xml" ,
168175 GetType ( ) . Assembly ) ;
169176
170- SchemaMetadataUpdater . QuoteTableAndColumns ( configuration ) ;
177+ var dialect = Dialect . Dialect . GetDialect ( configuration . GetDerivedProperties ( ) ) ;
178+ dialect . Keywords . Add ( "Abracadabra" ) ;
179+
180+ SchemaMetadataUpdater . Update ( configuration , dialect ) ;
181+ SchemaMetadataUpdater . QuoteTableAndColumns ( configuration , dialect ) ;
171182
172183 var cm = configuration . GetClassMapping ( typeof ( Order ) ) ;
173184 Assert . That ( cm . Table . IsQuoted ) ;
174185 var culs = new List < Column > ( cm . Table . ColumnIterator ) ;
175186 Assert . That ( GetColumnByName ( culs , "From" ) . IsQuoted ) ;
176187 Assert . That ( GetColumnByName ( culs , "And" ) . IsQuoted ) ;
177188 Assert . That ( GetColumnByName ( culs , "Select" ) . IsQuoted ) ;
189+ Assert . That ( GetColumnByName ( culs , "Abracadabra" ) . IsQuoted ) ;
178190 Assert . That ( ! GetColumnByName ( culs , "Name" ) . IsQuoted ) ;
179191 }
180192 }
0 commit comments