mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 18:52:50 +08:00
- 增加 pgsql 表达式树解析 hstore[""];
This commit is contained in:
parent
44e6eb2979
commit
441309e0d0
@ -175,9 +175,10 @@ namespace FreeSql.Tests.PostgreSQLExpression
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void HStore()
|
public void HStore()
|
||||||
{
|
{
|
||||||
|
|
||||||
var sql1 = select.Where(a => a.testFieldHStore.ContainsKey("a")).ToList();
|
var sql1 = select.Where(a => a.testFieldHStore.ContainsKey("a")).ToList();
|
||||||
var sql2 = select.Where(a => a.testFieldHStore.ContainsKey("a") == false).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")]
|
[Table(Name = "tb_alltype")]
|
||||||
|
@ -118,11 +118,12 @@ namespace FreeSql.KingbaseES
|
|||||||
if (objType != null || objType.IsArrayOrList())
|
if (objType != null || objType.IsArrayOrList())
|
||||||
{
|
{
|
||||||
string left = null;
|
string left = null;
|
||||||
if (objType.FullName == typeof(Dictionary<string, string>).FullName)
|
if (objType == typeof(Dictionary<string, string>))
|
||||||
{
|
{
|
||||||
left = objExp == null ? null : getExp(objExp);
|
left = objExp == null ? null : getExp(objExp);
|
||||||
switch (callExp.Method.Name)
|
switch (callExp.Method.Name)
|
||||||
{
|
{
|
||||||
|
case "get_Item": return $"{left}->{getExp(callExp.Arguments[argIndex])}";
|
||||||
case "Contains":
|
case "Contains":
|
||||||
var right = getExp(callExp.Arguments[argIndex]);
|
var right = getExp(callExp.Arguments[argIndex]);
|
||||||
return $"({left} @> ({right}))";
|
return $"({left} @> ({right}))";
|
||||||
|
@ -118,11 +118,12 @@ namespace FreeSql.Odbc.KingbaseES
|
|||||||
if (objType != null || objType.IsArrayOrList())
|
if (objType != null || objType.IsArrayOrList())
|
||||||
{
|
{
|
||||||
string left = null;
|
string left = null;
|
||||||
if (objType.FullName == typeof(Dictionary<string, string>).FullName)
|
if (objType == typeof(Dictionary<string, string>))
|
||||||
{
|
{
|
||||||
left = objExp == null ? null : getExp(objExp);
|
left = objExp == null ? null : getExp(objExp);
|
||||||
switch (callExp.Method.Name)
|
switch (callExp.Method.Name)
|
||||||
{
|
{
|
||||||
|
case "get_Item": return $"{left}->{getExp(callExp.Arguments[argIndex])}";
|
||||||
case "Contains":
|
case "Contains":
|
||||||
var right = getExp(callExp.Arguments[argIndex]);
|
var right = getExp(callExp.Arguments[argIndex]);
|
||||||
return $"({left} @> ({right}))";
|
return $"({left} @> ({right}))";
|
||||||
|
@ -118,11 +118,12 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
if (objType != null || objType.IsArrayOrList())
|
if (objType != null || objType.IsArrayOrList())
|
||||||
{
|
{
|
||||||
string left = null;
|
string left = null;
|
||||||
if (objType.FullName == typeof(Dictionary<string, string>).FullName)
|
if (objType == typeof(Dictionary<string, string>))
|
||||||
{
|
{
|
||||||
left = objExp == null ? null : getExp(objExp);
|
left = objExp == null ? null : getExp(objExp);
|
||||||
switch (callExp.Method.Name)
|
switch (callExp.Method.Name)
|
||||||
{
|
{
|
||||||
|
case "get_Item": return $"{left}->{getExp(callExp.Arguments[argIndex])}";
|
||||||
case "Contains":
|
case "Contains":
|
||||||
var right = getExp(callExp.Arguments[argIndex]);
|
var right = getExp(callExp.Arguments[argIndex]);
|
||||||
return $"({left} @> ({right}))";
|
return $"({left} @> ({right}))";
|
||||||
@ -206,7 +207,7 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (memParentExp.FullName == typeof(Dictionary<string, string>).FullName)
|
if (memParentExp == typeof(Dictionary<string, string>))
|
||||||
{
|
{
|
||||||
var left = getExp(memExp.Expression);
|
var left = getExp(memExp.Expression);
|
||||||
switch (memExp.Member.Name)
|
switch (memExp.Member.Name)
|
||||||
|
@ -149,11 +149,12 @@ namespace FreeSql.PostgreSQL
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (objType.FullName == typeof(Dictionary<string, string>).FullName)
|
if (objType == typeof(Dictionary<string, string>))
|
||||||
{
|
{
|
||||||
left = objExp == null ? null : getExp(objExp);
|
left = objExp == null ? null : getExp(objExp);
|
||||||
switch (callExp.Method.Name)
|
switch (callExp.Method.Name)
|
||||||
{
|
{
|
||||||
|
case "get_Item": return $"{left}->{getExp(callExp.Arguments[argIndex])}";
|
||||||
case "Contains":
|
case "Contains":
|
||||||
var right = getExp(callExp.Arguments[argIndex]);
|
var right = getExp(callExp.Arguments[argIndex]);
|
||||||
return $"({left} @> ({right}))";
|
return $"({left} @> ({right}))";
|
||||||
@ -237,7 +238,7 @@ namespace FreeSql.PostgreSQL
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (memParentExp.FullName == typeof(Dictionary<string, string>).FullName)
|
if (memParentExp == typeof(Dictionary<string, string>))
|
||||||
{
|
{
|
||||||
var left = getExp(memExp.Expression);
|
var left = getExp(memExp.Expression);
|
||||||
switch (memExp.Member.Name)
|
switch (memExp.Member.Name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user