|
5 | 5 | using System.IO; |
6 | 6 | using System.Reflection; |
7 | 7 | using System.Text; |
| 8 | +using ServiceStack.DataAnnotations; |
8 | 9 |
|
9 | 10 | namespace ServiceStack.OrmLite.VistaDB |
10 | 11 | { |
@@ -40,15 +41,13 @@ public VistaDbDialectProvider() |
40 | 41 | base.IntColumnDefinition = "INT"; |
41 | 42 | base.DefaultValueFormat = " DEFAULT {0}"; |
42 | 43 | base.TimeColumnDefinition = "BIGINT"; //TIME"; //SQLSERVER 2008+ |
| 44 | + base.MaxStringColumnDefinition = "VARCHAR(MAX)"; |
43 | 45 |
|
44 | 46 | base.InitColumnTypeMap(); |
45 | 47 | } |
46 | 48 |
|
47 | 49 | public override void OnAfterInitColumnTypeMap() |
48 | 50 | { |
49 | | - DbTypeMap.ColumnTypeMap.Remove(typeof(object)); |
50 | | - DbTypeMap.ColumnDbTypeMap.Remove(typeof(object)); |
51 | | - |
52 | 51 | DbTypeMap.Set<TimeSpan>(DbType.DateTime, TimeColumnDefinition); |
53 | 52 | DbTypeMap.Set<TimeSpan?>(DbType.DateTime, TimeColumnDefinition); |
54 | 53 | } |
@@ -156,10 +155,16 @@ public override string GetColumnDefinition(string fieldName, Type fieldType, |
156 | 155 | int? fieldLength, int? scale, string defaultValue, string customFieldDefinition) |
157 | 156 | { |
158 | 157 | string fieldDefinition; |
159 | | - if (fieldType == typeof(string)) |
160 | | - fieldDefinition = string.Format(this.StringLengthColumnDefinitionFormat, fieldLength.GetValueOrDefault(this.DefaultStringLength)); |
| 158 | + if (fieldType == typeof (string)) |
| 159 | + { |
| 160 | + fieldDefinition = fieldLength == StringLengthAttribute.MaxText |
| 161 | + ? MaxStringColumnDefinition |
| 162 | + : string.Format(StringLengthColumnDefinitionFormat, fieldLength.GetValueOrDefault(DefaultStringLength)); |
| 163 | + } |
161 | 164 | else if (!this.DbTypeMap.ColumnTypeMap.TryGetValue(fieldType, out fieldDefinition)) |
| 165 | + { |
162 | 166 | fieldDefinition = this.GetUndefinedColumnDefinition(fieldType, fieldLength); |
| 167 | + } |
163 | 168 |
|
164 | 169 | var sql = new StringBuilder(); |
165 | 170 | sql.AppendFormat("{0} {1}", this.GetQuotedColumnName(fieldName), fieldDefinition); |
|
0 commit comments