1
+ using System ;
1
2
using NHibernate . Cfg ;
2
3
using NHibernate . Engine ;
3
4
using NHibernate . Mapping ;
@@ -8,17 +9,24 @@ namespace NHibernate.Tool.hbm2ddl
8
9
// Candidate to be exstensions of ISessionFactory and Configuration
9
10
public static class SchemaMetadataUpdater
10
11
{
11
- public static void Update ( ISessionFactory sessionFactory )
12
+ public static void Update ( ISessionFactoryImplementor sessionFactory )
12
13
{
13
- var factory = ( ISessionFactoryImplementor ) sessionFactory ;
14
- var dialect = factory . Dialect ;
15
- var connectionHelper = new SuppliedConnectionProviderConnectionHelper ( factory . ConnectionProvider ) ;
16
- factory . Dialect . Keywords . UnionWith ( GetReservedWords ( dialect , connectionHelper ) ) ;
14
+ var dialect = sessionFactory . Dialect ;
15
+ var connectionHelper = new SuppliedConnectionProviderConnectionHelper ( sessionFactory . ConnectionProvider ) ;
16
+ sessionFactory . Dialect . Keywords . UnionWith ( GetReservedWords ( dialect , connectionHelper ) ) ;
17
17
}
18
18
19
19
public static void QuoteTableAndColumns ( Configuration configuration )
20
20
{
21
- ISet < string > reservedDb = GetReservedWords ( configuration . GetDerivedProperties ( ) ) ;
21
+ // Instatiates a new instance of the dialect so doesn't benefit from the Update call.
22
+ var dialect = Dialect . Dialect . GetDialect ( configuration . GetDerivedProperties ( ) ) ;
23
+ QuoteTableAndColumns ( configuration , dialect ) ;
24
+ }
25
+
26
+ public static void QuoteTableAndColumns ( Configuration configuration , Dialect . Dialect dialect )
27
+ {
28
+ ISet < string > reservedDb = dialect . Keywords ;
29
+
22
30
foreach ( var cm in configuration . ClassMappings )
23
31
{
24
32
QuoteTable ( cm . Table , reservedDb ) ;
@@ -29,16 +37,9 @@ public static void QuoteTableAndColumns(Configuration configuration)
29
37
}
30
38
}
31
39
32
- private static ISet < string > GetReservedWords ( IDictionary < string , string > cfgProperties )
33
- {
34
- var dialect = Dialect . Dialect . GetDialect ( cfgProperties ) ;
35
- var connectionHelper = new ManagedProviderConnectionHelper ( cfgProperties ) ;
36
- return GetReservedWords ( dialect , connectionHelper ) ;
37
- }
38
-
39
40
private static ISet < string > GetReservedWords ( Dialect . Dialect dialect , IConnectionHelper connectionHelper )
40
41
{
41
- ISet < string > reservedDb = new HashSet < string > ( ) ;
42
+ ISet < string > reservedDb = new HashSet < string > ( dialect . Keywords ) ;
42
43
connectionHelper . Prepare ( ) ;
43
44
try
44
45
{
0 commit comments