diff --git a/XCode/DataAccessLayer/Database/PostgreSQL.cs b/XCode/DataAccessLayer/Database/PostgreSQL.cs index c4bad4988..bcddc35e1 100644 --- a/XCode/DataAccessLayer/Database/PostgreSQL.cs +++ b/XCode/DataAccessLayer/Database/PostgreSQL.cs @@ -121,7 +121,7 @@ public override String FormatValue(IDataColumn? column, Object? value) } if (isArrayField) { - if (value is null) return isNullable ? "NULL" : "ARRAY[]"; + if (value is null) return isNullable ? "NULL" : "'{}'"; var count = 0; var builder = new StringBuilder(); builder.Append("ARRAY["); @@ -131,8 +131,16 @@ public override String FormatValue(IDataColumn? column, Object? value) builder.Append(','); count++; } - if (count != 0) builder.Length--; - builder.Append("]"); + if (count != 0) + { + builder.Length--; + builder.Append("]"); + } + else + { + builder.Clear(); + builder.Append("'{}'"); + } return builder.ToString(); } else @@ -414,11 +422,11 @@ public override Int32 Upsert(IDataTable table, IDataColumn[] columns, ICollectio { if (dc.Nullable) { - setters.Add(String.Format("{0} = EXCLUDED.{0},", db.FormatName(dc))); + setters.Add(String.Format("{0} = EXCLUDED.{0}", db.FormatName(dc))); } else { - setters.Add(String.Format("{0} = COALESCE(EXCLUDED.{0},{1}.{0}),", db.FormatName(dc), tb)); + setters.Add(String.Format("{0} = COALESCE(EXCLUDED.{0},{1}.{0})", db.FormatName(dc), tb)); } } } @@ -432,7 +440,7 @@ public override Int32 Upsert(IDataTable table, IDataColumn[] columns, ICollectio if (addColumns.Contains(dc.Name)) { - setters.Add(String.Format("{0} = EXCLUDED.{0} + {1}.{0},", db.FormatName(dc), tb)); + setters.Add(String.Format("{0} = EXCLUDED.{0} + {1}.{0}", db.FormatName(dc), tb)); } } }