diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/TDSQLForPG/DbBind/TDSQLForPGODBCDbBind.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/TDSQLForPG/DbBind/TDSQLForPGODBCDbBind.cs index 72583bf67..09d2bef15 100644 --- a/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/TDSQLForPG/DbBind/TDSQLForPGODBCDbBind.cs +++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/TDSQLForPG/DbBind/TDSQLForPGODBCDbBind.cs @@ -20,7 +20,7 @@ namespace SqlSugar.TDSQLForPGODBC if (csharpTypeName.ToLower().IsIn("boolean", "bool")) csharpTypeName = "bool"; if (csharpTypeName == "DateTimeOffset") - csharpTypeName = "DateTime"; + return "timestamptz"; var mappings = this.MappingTypes.Where(it => it.Value.ToString().Equals(csharpTypeName, StringComparison.CurrentCultureIgnoreCase)).ToList(); if (mappings != null && mappings.Count > 0) return mappings.First().Key; diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/TDSQLForPG/SqlBuilder/TDSQLForPGODBCExpressionContext.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/TDSQLForPG/SqlBuilder/TDSQLForPGODBCExpressionContext.cs index 5d16a29f3..a2a0df214 100644 --- a/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/TDSQLForPG/SqlBuilder/TDSQLForPGODBCExpressionContext.cs +++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/TDSQLForPG/SqlBuilder/TDSQLForPGODBCExpressionContext.cs @@ -452,6 +452,7 @@ namespace SqlSugar.TDSQLForPGODBC { result = GetJson(result, model.Args[5].MemberName, model.Args.Count() == 6); } + result = ConvertToJsonbIfEnabled(model, result); return result; } @@ -478,14 +479,14 @@ namespace SqlSugar.TDSQLForPGODBC { var parameter = model.Args[0]; //var parameter1 = model.Args[1]; - return $" json_array_length({parameter.MemberName}::json) "; + return ConvertToJsonbIfEnabled(model, $" json_array_length({parameter.MemberName}::json) "); } public override string JsonParse(MethodCallExpressionModel model) { var parameter = model.Args[0]; //var parameter1 = model.Args[1]; - return $" ({parameter.MemberName}::json) "; + return ConvertToJsonbIfEnabled(model, $" ({parameter.MemberName}::json) "); } public override string JsonArrayAny(MethodCallExpressionModel model) @@ -519,5 +520,19 @@ namespace SqlSugar.TDSQLForPGODBC return $" {model.Args[0].MemberName}::jsonb @> '[{{\"{model.Args[1].MemberValue}\":\"{model.Args[2].MemberValue.ObjToStringNoTrim().ToSqlFilter()}\"}}]'::jsonb "; } } + + private static string ConvertToJsonbIfEnabled(MethodCallExpressionModel model, string result) + { + if (model?.Conext?.SugarContext?.Context is ISqlSugarClient db) + { + if (db.CurrentConnectionConfig?.MoreSettings?.EnableJsonb == true) + { + result = result.Replace("::json", "::jsonb"); + } + } + + return result; + } + } }