- 增加 pgsql 表达式树解析 hstore[""];

This commit is contained in:
2881099 2020-11-23 10:56:55 +08:00
parent 44e6eb2979
commit 441309e0d0
5 changed files with 12 additions and 7 deletions

View File

@ -175,9 +175,10 @@ namespace FreeSql.Tests.PostgreSQLExpression
[Fact]
public void HStore()
{
var sql1 = select.Where(a => a.testFieldHStore.ContainsKey("a")).ToList();
var sql2 = select.Where(a => a.testFieldHStore.ContainsKey("a") == false).ToList();
var sql3 = select.Where(a => a.testFieldHStore["a"] == "xxx").ToList();
}
[Table(Name = "tb_alltype")]

View File

@ -118,11 +118,12 @@ namespace FreeSql.KingbaseES
if (objType != null || objType.IsArrayOrList())
{
string left = null;
if (objType.FullName == typeof(Dictionary<string, string>).FullName)
if (objType == typeof(Dictionary<string, string>))
{
left = objExp == null ? null : getExp(objExp);
switch (callExp.Method.Name)
{
case "get_Item": return $"{left}->{getExp(callExp.Arguments[argIndex])}";
case "Contains":
var right = getExp(callExp.Arguments[argIndex]);
return $"({left} @> ({right}))";

View File

@ -118,11 +118,12 @@ namespace FreeSql.Odbc.KingbaseES
if (objType != null || objType.IsArrayOrList())
{
string left = null;
if (objType.FullName == typeof(Dictionary<string, string>).FullName)
if (objType == typeof(Dictionary<string, string>))
{
left = objExp == null ? null : getExp(objExp);
switch (callExp.Method.Name)
{
case "get_Item": return $"{left}->{getExp(callExp.Arguments[argIndex])}";
case "Contains":
var right = getExp(callExp.Arguments[argIndex]);
return $"({left} @> ({right}))";

View File

@ -118,11 +118,12 @@ namespace FreeSql.Odbc.PostgreSQL
if (objType != null || objType.IsArrayOrList())
{
string left = null;
if (objType.FullName == typeof(Dictionary<string, string>).FullName)
if (objType == typeof(Dictionary<string, string>))
{
left = objExp == null ? null : getExp(objExp);
switch (callExp.Method.Name)
{
case "get_Item": return $"{left}->{getExp(callExp.Arguments[argIndex])}";
case "Contains":
var right = getExp(callExp.Arguments[argIndex]);
return $"({left} @> ({right}))";
@ -206,7 +207,7 @@ namespace FreeSql.Odbc.PostgreSQL
}
break;
}
if (memParentExp.FullName == typeof(Dictionary<string, string>).FullName)
if (memParentExp == typeof(Dictionary<string, string>))
{
var left = getExp(memExp.Expression);
switch (memExp.Member.Name)

View File

@ -149,11 +149,12 @@ namespace FreeSql.PostgreSQL
}
break;
}
if (objType.FullName == typeof(Dictionary<string, string>).FullName)
if (objType == typeof(Dictionary<string, string>))
{
left = objExp == null ? null : getExp(objExp);
switch (callExp.Method.Name)
{
case "get_Item": return $"{left}->{getExp(callExp.Arguments[argIndex])}";
case "Contains":
var right = getExp(callExp.Arguments[argIndex]);
return $"({left} @> ({right}))";
@ -237,7 +238,7 @@ namespace FreeSql.PostgreSQL
}
break;
}
if (memParentExp.FullName == typeof(Dictionary<string, string>).FullName)
if (memParentExp == typeof(Dictionary<string, string>))
{
var left = getExp(memExp.Expression);
switch (memExp.Member.Name)