mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-18 14:09:34 +08:00
Merge pull request #1091 from pinzi/SqlSugar5
修改QuestDB数据库时获取服务器时间为当前时区时间
This commit is contained in:
commit
401ad53369
@ -24,21 +24,39 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "now()";
|
//https://questdb.io/docs/guides/working-with-timestamps-timezones/#using-utc-offset-for-conversions
|
||||||
|
//https://questdb.io/docs/reference/function/date-time/#to_timezone
|
||||||
|
//SELECT
|
||||||
|
// now(), --2022-10-21T07:19:50.680134Z
|
||||||
|
// systimestamp(), --2022-10-21T07:19:50.680278Z
|
||||||
|
// sysdate(), --2022-10-21T07:19:50.679Z
|
||||||
|
// to_timezone(NOW(), 'Asia/ShangHai'), --2022-10-21T15:19:50.680134Z
|
||||||
|
// to_timezone(NOW(), 'HKT'), --2022-10-21T15:19:50.680134Z
|
||||||
|
// to_timezone(NOW(),'+08') --2022-10-21T15:19:50.680134Z
|
||||||
|
return $"to_timezone(NOW(),'{TimeZoneInfo.Local.BaseUtcOffset.Hours:00}')";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override string FullSqlDateNow
|
public override string FullSqlDateNow
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "select now()";
|
//https://questdb.io/docs/guides/working-with-timestamps-timezones/#using-utc-offset-for-conversions
|
||||||
|
//https://questdb.io/docs/reference/function/date-time/#to_timezone
|
||||||
|
//SELECT
|
||||||
|
// now(), --2022-10-21T07:19:50.680134Z
|
||||||
|
// systimestamp(), --2022-10-21T07:19:50.680278Z
|
||||||
|
// sysdate(), --2022-10-21T07:19:50.679Z
|
||||||
|
// to_timezone(NOW(), 'Asia/ShangHai'), --2022-10-21T15:19:50.680134Z
|
||||||
|
// to_timezone(NOW(), 'HKT'), --2022-10-21T15:19:50.680134Z
|
||||||
|
// to_timezone(NOW(),'+08') --2022-10-21T15:19:50.680134Z
|
||||||
|
return $"SELECT to_timezone(NOW(),'{TimeZoneInfo.Local.BaseUtcOffset.Hours:00}')";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool isAutoToLower => false;
|
public bool isAutoToLower => false;
|
||||||
public override string GetTranslationColumnName(string propertyName)
|
public override string GetTranslationColumnName(string propertyName)
|
||||||
{
|
{
|
||||||
if (propertyName.Contains(".")&& !propertyName.Contains(SqlTranslationLeft))
|
if (propertyName.Contains(".") && !propertyName.Contains(SqlTranslationLeft))
|
||||||
{
|
{
|
||||||
return string.Join(".", propertyName.Split('.').Select(it => $"{SqlTranslationLeft}{it.ToLower(isAutoToLower)}{SqlTranslationRight}"));
|
return string.Join(".", propertyName.Split('.').Select(it => $"{SqlTranslationLeft}{it.ToLower(isAutoToLower)}{SqlTranslationRight}"));
|
||||||
}
|
}
|
||||||
@ -74,7 +92,7 @@ namespace SqlSugar
|
|||||||
.MappingTables
|
.MappingTables
|
||||||
.FirstOrDefault(it => it.EntityName.Equals(name, StringComparison.CurrentCultureIgnoreCase));
|
.FirstOrDefault(it => it.EntityName.Equals(name, StringComparison.CurrentCultureIgnoreCase));
|
||||||
name = (mappingInfo == null ? name : mappingInfo.DbTableName);
|
name = (mappingInfo == null ? name : mappingInfo.DbTableName);
|
||||||
if (name.Contains(".")&& !name.Contains("(")&&!name.Contains("\".\""))
|
if (name.Contains(".") && !name.Contains("(") && !name.Contains("\".\""))
|
||||||
{
|
{
|
||||||
return string.Join(".", name.ToLower(isAutoToLower).Split('.').Select(it => SqlTranslationLeft + it + SqlTranslationRight));
|
return string.Join(".", name.ToLower(isAutoToLower).Split('.').Select(it => SqlTranslationLeft + it + SqlTranslationRight));
|
||||||
}
|
}
|
||||||
|
@ -24,21 +24,39 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "now()";
|
//https://questdb.io/docs/guides/working-with-timestamps-timezones/#using-utc-offset-for-conversions
|
||||||
|
//https://questdb.io/docs/reference/function/date-time/#to_timezone
|
||||||
|
//SELECT
|
||||||
|
// now(), --2022-10-21T07:19:50.680134Z
|
||||||
|
// systimestamp(), --2022-10-21T07:19:50.680278Z
|
||||||
|
// sysdate(), --2022-10-21T07:19:50.679Z
|
||||||
|
// to_timezone(NOW(), 'Asia/ShangHai'), --2022-10-21T15:19:50.680134Z
|
||||||
|
// to_timezone(NOW(), 'HKT'), --2022-10-21T15:19:50.680134Z
|
||||||
|
// to_timezone(NOW(),'+08') --2022-10-21T15:19:50.680134Z
|
||||||
|
return $"to_timezone(NOW(),'{TimeZoneInfo.Local.BaseUtcOffset.Hours:00}')";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override string FullSqlDateNow
|
public override string FullSqlDateNow
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "select now()";
|
//https://questdb.io/docs/guides/working-with-timestamps-timezones/#using-utc-offset-for-conversions
|
||||||
|
//https://questdb.io/docs/reference/function/date-time/#to_timezone
|
||||||
|
//SELECT
|
||||||
|
// now(), --2022-10-21T07:19:50.680134Z
|
||||||
|
// systimestamp(), --2022-10-21T07:19:50.680278Z
|
||||||
|
// sysdate(), --2022-10-21T07:19:50.679Z
|
||||||
|
// to_timezone(NOW(), 'Asia/ShangHai'), --2022-10-21T15:19:50.680134Z
|
||||||
|
// to_timezone(NOW(), 'HKT'), --2022-10-21T15:19:50.680134Z
|
||||||
|
// to_timezone(NOW(),'+08') --2022-10-21T15:19:50.680134Z
|
||||||
|
return $"SELECT to_timezone(NOW(),'{TimeZoneInfo.Local.BaseUtcOffset.Hours:00}')";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool isAutoToLower => false;
|
public bool isAutoToLower => false;
|
||||||
public override string GetTranslationColumnName(string propertyName)
|
public override string GetTranslationColumnName(string propertyName)
|
||||||
{
|
{
|
||||||
if (propertyName.Contains(".")&& !propertyName.Contains(SqlTranslationLeft))
|
if (propertyName.Contains(".") && !propertyName.Contains(SqlTranslationLeft))
|
||||||
{
|
{
|
||||||
return string.Join(".", propertyName.Split('.').Select(it => $"{SqlTranslationLeft}{it.ToLower(isAutoToLower)}{SqlTranslationRight}"));
|
return string.Join(".", propertyName.Split('.').Select(it => $"{SqlTranslationLeft}{it.ToLower(isAutoToLower)}{SqlTranslationRight}"));
|
||||||
}
|
}
|
||||||
@ -74,7 +92,7 @@ namespace SqlSugar
|
|||||||
.MappingTables
|
.MappingTables
|
||||||
.FirstOrDefault(it => it.EntityName.Equals(name, StringComparison.CurrentCultureIgnoreCase));
|
.FirstOrDefault(it => it.EntityName.Equals(name, StringComparison.CurrentCultureIgnoreCase));
|
||||||
name = (mappingInfo == null ? name : mappingInfo.DbTableName);
|
name = (mappingInfo == null ? name : mappingInfo.DbTableName);
|
||||||
if (name.Contains(".")&& !name.Contains("(")&&!name.Contains("\".\""))
|
if (name.Contains(".") && !name.Contains("(") && !name.Contains("\".\""))
|
||||||
{
|
{
|
||||||
return string.Join(".", name.ToLower(isAutoToLower).Split('.').Select(it => SqlTranslationLeft + it + SqlTranslationRight));
|
return string.Join(".", name.ToLower(isAutoToLower).Split('.').Select(it => SqlTranslationLeft + it + SqlTranslationRight));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user