Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 95520fd

Browse files
committed
Fix string[] pgsql error
1 parent 63761f1 commit 95520fd

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/ServiceStack.OrmLite.PostgreSQL/Converters/PostgreSqlArrayConverters.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,37 @@ public override string ColumnDefinition
2626
get { return "text[]"; }
2727
}
2828

29+
public override DbType DbType
30+
{
31+
get { return DbType.Object; }
32+
}
33+
34+
public override string GetColumnDefinition(int? stringLength)
35+
{
36+
return stringLength != null
37+
? base.GetColumnDefinition(stringLength)
38+
: ColumnDefinition;
39+
}
40+
2941
public override string ToQuotedString(Type fieldType, object value)
3042
{
3143
var stringArray = (string[])value;
3244
return this.ToArray(stringArray);
3345
}
3446

47+
public override object ToDbValue(Type fieldType, object value)
48+
{
49+
return fieldType == typeof(string[])
50+
? value
51+
: DialectProvider.StringSerializer.SerializeToString(value);
52+
}
53+
3554
public override object FromDbValue(Type fieldType, object value)
3655
{
37-
return value;
56+
var strVal = value as string;
57+
return strVal != null
58+
? strVal.FromJson<string[]>()
59+
: value;
3860
}
3961
}
4062

0 commit comments

Comments
 (0)