mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
Merge pull request #747 from hd2y/master
修复 pgsql 中 hstore 中 value 错误赋值为 key 的问题,并允许 value 值为 NULL。
This commit is contained in:
commit
dabc95ae32
6
.gitignore
vendored
6
.gitignore
vendored
@ -244,4 +244,8 @@ ModelManifest.xml
|
|||||||
.paket/paket.exe
|
.paket/paket.exe
|
||||||
|
|
||||||
# FAKE - F# Make
|
# FAKE - F# Make
|
||||||
.fake/
|
.fake/
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
.idea/
|
||||||
|
*.sln.iml
|
@ -7,6 +7,7 @@ using System;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
@ -65,12 +66,22 @@ namespace FreeSql.PostgreSQL
|
|||||||
{
|
{
|
||||||
var pgdics = isdic ? param as Dictionary<string, string> :
|
var pgdics = isdic ? param as Dictionary<string, string> :
|
||||||
param as IEnumerable<KeyValuePair<string, string>>;
|
param as IEnumerable<KeyValuePair<string, string>>;
|
||||||
if (pgdics == null) return string.Concat("''::hstore");
|
|
||||||
var pghstore = new StringBuilder();
|
var pghstore = new StringBuilder("'");
|
||||||
pghstore.Append("'");
|
var pairs = pgdics.ToArray();
|
||||||
foreach (var dic in pgdics)
|
|
||||||
pghstore.Append("\"").Append(dic.Key.Replace("'", "''")).Append("\"=>")
|
for (var i = 0; i < pairs.Length; i++)
|
||||||
.Append(dic.Key.Replace("'", "''")).Append(",");
|
{
|
||||||
|
if (i != 0) pghstore.Append(",");
|
||||||
|
|
||||||
|
pghstore.AppendFormat("\"{0}\"=>", pairs[i].Key.Replace("'", "''"));
|
||||||
|
|
||||||
|
if (pairs[i].Value == null)
|
||||||
|
pghstore.Append("NULL");
|
||||||
|
else
|
||||||
|
pghstore.AppendFormat("\"{0}\"", pairs[i].Value.Replace("'", "''"));
|
||||||
|
}
|
||||||
|
|
||||||
return pghstore.Append("'::hstore");
|
return pghstore.Append("'::hstore");
|
||||||
}
|
}
|
||||||
else if (param is IEnumerable)
|
else if (param is IEnumerable)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user