@@ -9,6 +9,7 @@ namespace ServiceStack.OrmLite.PostgreSQL
9
9
public class PostgreSQLDialectProvider : OrmLiteDialectProviderBase < PostgreSQLDialectProvider >
10
10
{
11
11
public static PostgreSQLDialectProvider Instance = new PostgreSQLDialectProvider ( ) ;
12
+ const string textColumnDefinition = "text" ;
12
13
13
14
private PostgreSQLDialectProvider ( )
14
15
{
@@ -22,7 +23,10 @@ private PostgreSQLDialectProvider()
22
23
base . ParamString = ":" ;
23
24
base . BlobColumnDefinition = "bytea" ;
24
25
base . RealColumnDefinition = "double precision" ;
25
- base . StringLengthColumnDefinitionFormat = "text" ;
26
+ base . StringLengthColumnDefinitionFormat = textColumnDefinition ;
27
+ //there is no "n"varchar in postgres. All strings are either unicode or non-unicode, inherited from the database.
28
+ base . StringLengthUnicodeColumnDefinitionFormat = "character varying({0})" ;
29
+ base . StringLengthNonUnicodeColumnDefinitionFormat = "character varying({0})" ;
26
30
base . InitColumnTypeMap ( ) ;
27
31
28
32
DbTypeMap . Set < TimeSpan > ( DbType . Time , "Interval" ) ;
@@ -44,13 +48,11 @@ public override string GetColumnDefinition(
44
48
{
45
49
if ( fieldLength != null )
46
50
{
47
- fieldDefinition = UseUnicode
48
- ? string . Format ( base . StringLengthUnicodeColumnDefinitionFormat , fieldLength )
49
- : string . Format ( base . StringLengthNonUnicodeColumnDefinitionFormat , fieldLength ) ;
51
+ fieldDefinition = string . Format ( base . StringLengthColumnDefinitionFormat , fieldLength ) ;
50
52
}
51
53
else
52
54
{
53
- fieldDefinition = StringLengthColumnDefinitionFormat ;
55
+ fieldDefinition = textColumnDefinition ;
54
56
}
55
57
}
56
58
else
0 commit comments