mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-16 04:59:34 +08:00
QuestDb
This commit is contained in:
parent
1f8a5cdef7
commit
97c84ab88b
@ -103,40 +103,7 @@ namespace SqlSugar
|
||||
sqlParameter.Direction = parameter.Direction;
|
||||
if (parameter.IsJson)
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Json;
|
||||
}
|
||||
if (parameter.IsArray)
|
||||
{
|
||||
// sqlParameter.Value = this.Context.Utilities.SerializeObject(sqlParameter.Value);
|
||||
var type = sqlParameter.Value.GetType();
|
||||
if (ArrayMapping.ContainsKey(type))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = ArrayMapping[type] | NpgsqlDbType.Array;
|
||||
}
|
||||
else if (type==DBNull.Value.GetType())
|
||||
{
|
||||
if (parameter.DbType.IsIn(System.Data.DbType.Int32))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Integer | NpgsqlDbType.Array;
|
||||
}
|
||||
else if (parameter.DbType.IsIn(System.Data.DbType.Int16))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Smallint | NpgsqlDbType.Array;
|
||||
}
|
||||
else if (parameter.DbType.IsIn(System.Data.DbType.Int64))
|
||||
{
|
||||
sqlParameter.NpgsqlDbType = NpgsqlDbType.Bigint | NpgsqlDbType.Array;
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlParameter.NpgsqlDbType =NpgsqlDbType.Text | NpgsqlDbType.Array;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Check.Exception(true, sqlParameter.Value.GetType().Name + " No Support");
|
||||
}
|
||||
sqlParameter.DbType=System.Data.DbType.String;
|
||||
}
|
||||
if (sqlParameter.Direction == 0)
|
||||
{
|
||||
@ -149,14 +116,19 @@ namespace SqlSugar
|
||||
this.OutputParameters.RemoveAll(it => it.ParameterName == sqlParameter.ParameterName);
|
||||
this.OutputParameters.Add(sqlParameter);
|
||||
}
|
||||
if (isVarchar && sqlParameter.DbType == System.Data.DbType.String)
|
||||
if (sqlParameter.DbType == System.Data.DbType.String)
|
||||
{
|
||||
sqlParameter.DbType = System.Data.DbType.AnsiString;
|
||||
}
|
||||
if (sqlParameter.Value is DateTime && sqlParameter.DbType == System.Data.DbType.AnsiString)
|
||||
else if (sqlParameter.Value is DateTime && sqlParameter.DbType == System.Data.DbType.AnsiString)
|
||||
{
|
||||
sqlParameter.DbType = System.Data.DbType.DateTime;
|
||||
}
|
||||
else if (sqlParameter.DbType==System.Data.DbType.Decimal)
|
||||
{
|
||||
sqlParameter.DbType = System.Data.DbType.Double;
|
||||
sqlParameter.Value = Convert.ToDouble(sqlParameter.Value);
|
||||
}
|
||||
++index;
|
||||
}
|
||||
return result;
|
||||
|
@ -46,10 +46,10 @@ namespace SqlSugar
|
||||
string columnParametersString = string.Join(",", this.DbColumnInfoList.Select(it =>
|
||||
{
|
||||
var spk = Builder.SqlParameterKeyWord + it.DbColumnName;
|
||||
if (it.Value is DateTime)
|
||||
{
|
||||
return $"to_timestamp('{it.Value.ObjToString("yyyy-MM-ddTHH:mm:ss")}', 'yyyy-MM-ddTHH:mm:ss')";
|
||||
}
|
||||
//if (it.Value is DateTime)
|
||||
//{
|
||||
// return $"to_timestamp('{it.Value.ObjToString("yyyy-MM-ddTHH:mm:ss")}', 'yyyy-MM-ddTHH:mm:ss')";
|
||||
//}
|
||||
return spk;
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,9 @@ namespace SqlSugar
|
||||
get
|
||||
{
|
||||
/*
|
||||
SELECT * FROM TABLE WHERE CONDITION ORDER BY ID DESC LIMIT 10 offset 0
|
||||
SELECT * FROM TABLE WHERE CONDITION ORDER BY ID DESC LIMIT 0,10
|
||||
*/
|
||||
var template = "SELECT {0} FROM {1} {2} {3} {4} LIMIT {6} offset {5}";
|
||||
var template = "SELECT {0} FROM {1} {2} {3} {4} LIMIT {5},{6}";
|
||||
return template;
|
||||
}
|
||||
}
|
||||
@ -31,7 +31,7 @@ namespace SqlSugar
|
||||
#region Common Methods
|
||||
public override bool IsComplexModel(string sql)
|
||||
{
|
||||
return Regex.IsMatch(sql, @"AS ""\w+\.\w+""")|| Regex.IsMatch(sql, @"AS ""\w+\.\w+\.\w+""");
|
||||
return Regex.IsMatch(sql, @"AS \`\w+\.\w+\`") || Regex.IsMatch(sql, @"AS \`\w+\.\w+\.\w+\`");
|
||||
}
|
||||
public override string ToSqlString()
|
||||
{
|
||||
@ -72,7 +72,54 @@ namespace SqlSugar
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private string ToCountSqlString()
|
||||
{
|
||||
//base.AppendFilter();
|
||||
string oldOrderValue = this.OrderByValue;
|
||||
string result = null;
|
||||
sql = new StringBuilder();
|
||||
sql.AppendFormat(SqlTemplate, "Count(*)", GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString);
|
||||
if (IsCount)
|
||||
{
|
||||
if (sql.ToString().Contains("-- No table"))
|
||||
{
|
||||
return "-- No table";
|
||||
}
|
||||
return sql.ToString();
|
||||
}
|
||||
if (Skip != null && Take == null)
|
||||
{
|
||||
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
|
||||
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString, Skip.ObjToInt(), long.MaxValue);
|
||||
}
|
||||
else if (Skip == null && Take != null)
|
||||
{
|
||||
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
|
||||
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, 0, Take.ObjToInt());
|
||||
}
|
||||
else if (Skip != null && Take != null)
|
||||
{
|
||||
if (this.OrderByValue == "ORDER BY ") this.OrderByValue += GetSelectValue.Split(',')[0];
|
||||
result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, Skip.ObjToInt() > 0 ? Skip.ObjToInt() : 0, Take);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = sql.ToString();
|
||||
}
|
||||
this.OrderByValue = oldOrderValue;
|
||||
return result;
|
||||
}
|
||||
public override string ToCountSql(string sql)
|
||||
{
|
||||
if (this.GroupByValue.HasValue())
|
||||
{
|
||||
return base.ToCountSql(sql);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ToCountSqlString();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Get SQL Partial
|
||||
@ -95,7 +142,7 @@ namespace SqlSugar
|
||||
}
|
||||
if (IsDistinct)
|
||||
{
|
||||
result = "distinct "+result;
|
||||
result = " DISTINCT " + result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user