From e9b0b53acd4df6c4302aa14690082458d2a70f6f Mon Sep 17 00:00:00 2001 From: xiaopinzi Date: Fri, 21 Oct 2022 16:08:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9QuestDB=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E6=97=B6=E8=8E=B7=E5=8F=96=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E4=B8=BA=E5=BD=93=E5=89=8D=E6=97=B6=E5=8C=BA?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QuestDB/SqlBuilder/QuestDBBuilder.cs | 26 ++++++++++++++++--- .../QuestDB/SqlBuilder/QuestDBBuilder.cs | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Realization/QuestDB/SqlBuilder/QuestDBBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/QuestDB/SqlBuilder/QuestDBBuilder.cs index 8ebd2918c..789deab2d 100644 --- a/Src/Asp.Net/SqlSugar/Realization/QuestDB/SqlBuilder/QuestDBBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/QuestDB/SqlBuilder/QuestDBBuilder.cs @@ -24,21 +24,39 @@ namespace SqlSugar { 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 { 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 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}")); } @@ -74,7 +92,7 @@ namespace SqlSugar .MappingTables .FirstOrDefault(it => it.EntityName.Equals(name, StringComparison.CurrentCultureIgnoreCase)); 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)); } diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/QuestDB/SqlBuilder/QuestDBBuilder.cs b/Src/Asp.NetCore2/SqlSugar/Realization/QuestDB/SqlBuilder/QuestDBBuilder.cs index a85c22fd8..789deab2d 100644 --- a/Src/Asp.NetCore2/SqlSugar/Realization/QuestDB/SqlBuilder/QuestDBBuilder.cs +++ b/Src/Asp.NetCore2/SqlSugar/Realization/QuestDB/SqlBuilder/QuestDBBuilder.cs @@ -24,6 +24,7 @@ namespace SqlSugar { get { + //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 @@ -39,6 +40,7 @@ namespace SqlSugar { get { + //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