@@ -10,28 +10,28 @@ namespace Migrator.Providers
1010 /// </summary>
1111 public class ColumnPropertiesMapper
1212 {
13+ protected Dialect dialect ;
14+
15+ /// <summary>The SQL type</summary>
16+ protected string type ;
17+
18+ /// <summary>The name of the column</summary>
19+ protected string name ;
20+
1321 /// <summary>
1422 /// the type of the column
1523 /// </summary>
1624 protected string columnSql ;
1725
1826 /// <summary>
19- /// Sql if this column has a default value
27+ /// Sql if This column is Indexed
2028 /// </summary>
21- protected object defaultVal ;
22-
23- protected Dialect dialect ;
29+ protected bool indexed = false ;
2430
2531 /// <summary>
26- /// Sql if This column is Indexed
32+ /// Sql if this column has a default value
2733 /// </summary>
28- protected bool indexed ;
29-
30- /// <summary>The name of the column</summary>
31- protected string name ;
32-
33- /// <summary>The SQL type</summary>
34- protected string type ;
34+ protected object defaultVal ;
3535
3636 public ColumnPropertiesMapper ( Dialect dialect , string type )
3737 {
@@ -79,18 +79,18 @@ public void MapColumnProperties(Column column)
7979 Name = column . Name ;
8080 indexed = PropertySelected ( column . ColumnProperty , ColumnProperty . Indexed ) ;
8181
82- var vals = new List < string > ( ) ;
83- vals . Add ( dialect . ColumnNameNeedsQuote ? QuotedName : Name ) ;
82+ List < string > vals = new List < string > ( ) ;
83+ vals . Add ( dialect . ColumnNameNeedsQuote || dialect . IsReservedWord ( Name ) ? QuotedName : Name ) ;
8484
8585 vals . Add ( type ) ;
8686
87- if ( ! dialect . IdentityNeedsType )
87+ if ( ! dialect . IdentityNeedsType )
8888 AddValueIfSelected ( column , ColumnProperty . Identity , vals ) ;
8989
9090 if ( dialect . IsUnsignedCompatible ( column . Type ) )
9191 AddValueIfSelected ( column , ColumnProperty . Unsigned , vals ) ;
9292
93- if ( ! PropertySelected ( column . ColumnProperty , ColumnProperty . PrimaryKey ) || dialect . NeedsNotNullForIdentity )
93+ if ( ! PropertySelected ( column . ColumnProperty , ColumnProperty . PrimaryKey ) || dialect . NeedsNotNullForIdentity )
9494 AddValueIfSelected ( column , ColumnProperty . NotNull , vals ) ;
9595
9696 AddValueIfSelected ( column , ColumnProperty . PrimaryKey , vals ) ;
@@ -107,7 +107,7 @@ public void MapColumnProperties(Column column)
107107 columnSql = String . Join ( " " , vals . ToArray ( ) ) ;
108108 }
109109
110- void AddValueIfSelected ( Column column , ColumnProperty property , ICollection < string > vals )
110+ private void AddValueIfSelected ( Column column , ColumnProperty property , ICollection < string > vals )
111111 {
112112 if ( PropertySelected ( column . ColumnProperty , property ) )
113113 vals . Add ( dialect . SqlForProperty ( property ) ) ;
@@ -118,4 +118,4 @@ public static bool PropertySelected(ColumnProperty source, ColumnProperty compar
118118 return ( source & comparison ) == comparison ;
119119 }
120120 }
121- }
121+ }
0 commit comments