From fec67ad1234363de7d3360c25db789a506d21a86 Mon Sep 17 00:00:00 2001 From: MysticBoy Date: Fri, 15 Dec 2023 11:47:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7ef=E4=BE=9D=E8=B5=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IoTSharp.EntityFrameworkCore.Taos.csproj | 10 ++--- .../Query/Internal/TaosQuerySqlGenerator.cs | 7 +--- .../Update/Internal/TaosUpdateSqlGenerator.cs | 41 ++----------------- .../EntityFrameworkCore.Taos.Tests.csproj | 12 +++--- .../SqModelTest.cs | 13 +++--- src/Example/Example.csproj | 6 +-- .../IoTSharp.Data.Taos.csproj | 2 +- .../IoTSharp.HealthChecks.Taos.csproj | 4 +- 8 files changed, 28 insertions(+), 67 deletions(-) diff --git a/src/EFCore.Taos.Core/IoTSharp.EntityFrameworkCore.Taos.csproj b/src/EFCore.Taos.Core/IoTSharp.EntityFrameworkCore.Taos.csproj index 85a9312..9872e48 100644 --- a/src/EFCore.Taos.Core/IoTSharp.EntityFrameworkCore.Taos.csproj +++ b/src/EFCore.Taos.Core/IoTSharp.EntityFrameworkCore.Taos.csproj @@ -25,14 +25,14 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/src/EFCore.Taos.Core/Query/Internal/TaosQuerySqlGenerator.cs b/src/EFCore.Taos.Core/Query/Internal/TaosQuerySqlGenerator.cs index 4661516..df2c316 100644 --- a/src/EFCore.Taos.Core/Query/Internal/TaosQuerySqlGenerator.cs +++ b/src/EFCore.Taos.Core/Query/Internal/TaosQuerySqlGenerator.cs @@ -42,12 +42,7 @@ protected override Expression VisitTable(TableExpression tableExpression) return tableExpression; } - [System.Obsolete] - protected override string GenerateOperator(SqlBinaryExpression binaryExpression) - => binaryExpression.OperatorType == ExpressionType.Add - && binaryExpression.Type == typeof(string) - ? " || " - : base.GetOperator(binaryExpression); + protected override void GenerateLimitOffset(SelectExpression selectExpression) { diff --git a/src/EFCore.Taos.Core/Update/Internal/TaosUpdateSqlGenerator.cs b/src/EFCore.Taos.Core/Update/Internal/TaosUpdateSqlGenerator.cs index d2c7ca2..a767fa0 100644 --- a/src/EFCore.Taos.Core/Update/Internal/TaosUpdateSqlGenerator.cs +++ b/src/EFCore.Taos.Core/Update/Internal/TaosUpdateSqlGenerator.cs @@ -41,49 +41,14 @@ public TaosUpdateSqlGenerator([NotNull] UpdateSqlGeneratorDependencies dependenc : base(dependencies) { } - - protected override void AppendDeleteCommand(StringBuilder commandStringBuilder, string name, string schema, IReadOnlyList conditionOperations) - { - base.AppendDeleteCommand(commandStringBuilder, name, schema, conditionOperations); - } protected override void AppendDeleteCommandHeader(StringBuilder commandStringBuilder, string name, string schema) { base.AppendDeleteCommandHeader(commandStringBuilder, name, schema); } - protected override ResultSetMapping AppendSelectAffectedCommand(StringBuilder commandStringBuilder, string name, string schema, IReadOnlyList readOperations, IReadOnlyList conditionOperations, int commandPosition) - { - Check.NotNull(commandStringBuilder, nameof(commandStringBuilder)); - Check.NotEmpty(name, nameof(name)); - - commandStringBuilder - .Append("SELECT changes()") - .AppendLine(SqlGenerationHelper.StatementTerminator) - .AppendLine(); - - return ResultSetMapping.LastInResultSet; - } - protected override void AppendIdentityWhereCondition(StringBuilder commandStringBuilder, IColumnModification columnModification) - { - - Check.NotNull(commandStringBuilder, nameof(commandStringBuilder)); - Check.NotNull(columnModification, nameof(columnModification)); - SqlGenerationHelper.DelimitIdentifier(commandStringBuilder, "rowid"); - commandStringBuilder.Append(" = ") - .Append("last_insert_rowid()"); - } - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// any release. You should only use it directly in your code with extreme caution and knowing that - /// doing so can result in application failures when updating to a new Entity Framework Core release. - /// - protected override void AppendRowsAffectedWhereCondition(StringBuilder commandStringBuilder, int expectedRowsAffected) - { - Check.NotNull(commandStringBuilder, nameof(commandStringBuilder)); - - commandStringBuilder.Append("changes() = ").Append(expectedRowsAffected); - } + + + /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EntityFrameworkCore.Taos.Tests/EntityFrameworkCore.Taos.Tests.csproj b/src/EntityFrameworkCore.Taos.Tests/EntityFrameworkCore.Taos.Tests.csproj index fb642e0..38df2d4 100644 --- a/src/EntityFrameworkCore.Taos.Tests/EntityFrameworkCore.Taos.Tests.csproj +++ b/src/EntityFrameworkCore.Taos.Tests/EntityFrameworkCore.Taos.Tests.csproj @@ -6,16 +6,16 @@ + - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/src/EntityFrameworkCore.Taos.Tests/SqModelTest.cs b/src/EntityFrameworkCore.Taos.Tests/SqModelTest.cs index 875df38..789f8a7 100644 --- a/src/EntityFrameworkCore.Taos.Tests/SqModelTest.cs +++ b/src/EntityFrameworkCore.Taos.Tests/SqModelTest.cs @@ -1,6 +1,6 @@ -using IoTSharp.Data.Taos; +using Carbunql.Analysis; +using IoTSharp.Data.Taos; using Microsoft.VisualStudio.TestTools.UnitTesting; -using SqModel.Analysis; using System; using System.Collections.Generic; using System.Linq; @@ -20,9 +20,9 @@ public void TestExecuteBulkInsert_Json() ,station_uid,longitude,latitude,mn,dev_code,pol_name,pol_unit,pol_id FROM st_pmcm WHERE point_code = @p1;"; const string SQLDemo3 = "SELECT * FROM bytable WHERE t1 = @t1 AND t2 LIKE @t11 LIMIT @t3;"; // const string SQLDemo4 = "INSERT INTO t_status USING st_status (status_key) TAGS ('s1') (status_time, val) VALUES (@x1, @x2);"; - var s1 = SqlParser.Parse(SQLDemo1); + var s1 = SelectQueryParser.Parse(SQLDemo1); Assert.AreEqual(0, ((int?)s1.Parameters?.Count).GetValueOrDefault()); - var s2 = SqlParser.Parse(SQLDemo2); + var s2 = SelectQueryParser.Parse(SQLDemo2); Assert.AreEqual(5, ((int?)s2.Parameters?.Count).GetValueOrDefault()); Assert.AreEqual("@p1", s2.Parameters?.Keys.ToArray()[0]); @@ -30,7 +30,7 @@ public void TestExecuteBulkInsert_Json() var pn2 = s2.Parameters; Assert.AreEqual(1, pn2.Count); Assert.AreEqual("@p1", pn2.Keys.ToArray()[0]); - var s3 = SqlParser.Parse(SQLDemo3); + var s3 = SelectQueryParser.Parse(SQLDemo3); Assert.AreEqual(7, s3.Parameters?.Count); Assert.AreEqual("@t1", s3.Parameters?.ToArray()[1].Key); Assert.AreEqual("@t11", s3.Parameters?.ToArray()[3].Key); @@ -57,7 +57,8 @@ public void TestExecuteBulkInsert_Json() //Assert.AreEqual(2, pn4.Length); //Assert.AreEqual("@x1", pn4[0]); //Assert.AreEqual("@x2", pn4[1]); - var s5 = SqlParser.Parse("insert into #subtable using stable tags($t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$t12,$t13) values (@t1,@t2,@t3,@t4,@t5,@t6,@t7,@t8,@t9,@t10,@t11,@t12,@t13,@t14)"); + + var s5 = SelectQueryParser.Parse("insert into #subtable using stable tags($t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$t12,$t13) values (@t1,@t2,@t3,@t4,@t5,@t6,@t7,@t8,@t9,@t10,@t11,@t12,@t13,@t14)"); Assert.AreEqual(14, s5.Parameters?.Count); Assert.AreEqual("#subtable", s5.Parameters?.ToArray()[0].Key); Assert.AreEqual(13, s5.Parameters?.Count(k=>k.Key.StartsWith('$'))); diff --git a/src/Example/Example.csproj b/src/Example/Example.csproj index 421c24d..109bb64 100644 --- a/src/Example/Example.csproj +++ b/src/Example/Example.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/src/IoTSharp.Data.Taos/IoTSharp.Data.Taos.csproj b/src/IoTSharp.Data.Taos/IoTSharp.Data.Taos.csproj index a466c7a..31dbd69 100644 --- a/src/IoTSharp.Data.Taos/IoTSharp.Data.Taos.csproj +++ b/src/IoTSharp.Data.Taos/IoTSharp.Data.Taos.csproj @@ -56,7 +56,7 @@ - + diff --git a/src/IoTSharp.HealthChecks.Taos/IoTSharp.HealthChecks.Taos.csproj b/src/IoTSharp.HealthChecks.Taos/IoTSharp.HealthChecks.Taos.csproj index 1905e8f..aeb973a 100644 --- a/src/IoTSharp.HealthChecks.Taos/IoTSharp.HealthChecks.Taos.csproj +++ b/src/IoTSharp.HealthChecks.Taos/IoTSharp.HealthChecks.Taos.csproj @@ -17,8 +17,8 @@ - - + +