Skip to content

Commit c4b4fac

Browse files
committed
QuestDb 单元测试验证
1 parent 7e4d248 commit c4b4fac

File tree

8 files changed

+210
-185
lines changed

8 files changed

+210
-185
lines changed

FreeSql.sln

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Tests.Provider.TDen
137137
EndProject
138138
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Extensions.EFModel", "Extensions\FreeSql.Extensions.EFModel\FreeSql.Extensions.EFModel.csproj", "{4281AC48-6FE7-49C3-BE7B-D029058646BC}"
139139
EndProject
140+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeSql.Tests.Provider.QuestDb", "FreeSql.Tests\FreeSql.Tests.Provider.QuestDb\FreeSql.Tests.Provider.QuestDb.csproj", "{5A59200F-9757-4E0B-B4CF-2E846F25A69A}"
141+
EndProject
140142
Global
141143
GlobalSection(SolutionConfigurationPlatforms) = preSolution
142144
Debug|Any CPU = Debug|Any CPU
@@ -831,6 +833,18 @@ Global
831833
{4281AC48-6FE7-49C3-BE7B-D029058646BC}.Release|x64.Build.0 = Release|Any CPU
832834
{4281AC48-6FE7-49C3-BE7B-D029058646BC}.Release|x86.ActiveCfg = Release|Any CPU
833835
{4281AC48-6FE7-49C3-BE7B-D029058646BC}.Release|x86.Build.0 = Release|Any CPU
836+
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
837+
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Debug|Any CPU.Build.0 = Debug|Any CPU
838+
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Debug|x64.ActiveCfg = Debug|Any CPU
839+
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Debug|x64.Build.0 = Debug|Any CPU
840+
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Debug|x86.ActiveCfg = Debug|Any CPU
841+
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Debug|x86.Build.0 = Debug|Any CPU
842+
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Release|Any CPU.ActiveCfg = Release|Any CPU
843+
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Release|Any CPU.Build.0 = Release|Any CPU
844+
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Release|x64.ActiveCfg = Release|Any CPU
845+
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Release|x64.Build.0 = Release|Any CPU
846+
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Release|x86.ActiveCfg = Release|Any CPU
847+
{5A59200F-9757-4E0B-B4CF-2E846F25A69A}.Release|x86.Build.0 = Release|Any CPU
834848
EndGlobalSection
835849
GlobalSection(SolutionProperties) = preSolution
836850
HideSolutionNode = FALSE
@@ -877,8 +891,8 @@ Global
877891
{4281AC48-6FE7-49C3-BE7B-D029058646BC} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA}
878892
EndGlobalSection
879893
GlobalSection(ExtensibilityGlobals) = postSolution
880-
SolutionGuid = {089687FD-5D25-40AB-BA8A-A10D1E137F98}
881-
RESX_PrefixTranslations = True
882894
RESX_NeutralResourcesLanguage = en-US
895+
RESX_PrefixTranslations = True
896+
SolutionGuid = {089687FD-5D25-40AB-BA8A-A10D1E137F98}
883897
EndGlobalSection
884898
EndGlobal

FreeSql/FreeSql.xml

Lines changed: 109 additions & 123 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Providers/FreeSql.Provider.QuestDb/Curd/QuestDbInsert.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
using FreeSql.Internal;
22
using FreeSql.Internal.Model;
3+
using FreeSql.Provider.QuestDb;
4+
using FreeSql.Provider.QuestDb.Models;
35
using Newtonsoft.Json;
46
using System;
57
using System.Collections;
68
using System.Collections.Generic;
79
using System.Data;
810
using System.Data.Common;
911
using System.Linq;
12+
using System.Net.Http;
1013
using System.Text;
1114
using System.Threading;
1215
using System.Threading.Tasks;
13-
using FreeSql.Provider.QuestDb;
1416

1517
namespace FreeSql.QuestDb.Curd
1618
{
@@ -33,16 +35,16 @@ public QuestDbInsert(IFreeSql orm, CommonUtils commonUtils, CommonExpression com
3335
internal void InternalClearData() => ClearData();
3436
internal string InternalTableRuleInvoke() => TableRuleInvoke();
3537

36-
private int RestApiExecuteAffrows()
38+
private async Task<int> RestApiExecuteAffrowsAsync()
3739
{
3840
//如果设置了RestAPI的Url则走HTTP
39-
var apiFeatures = ServiceContainer.GetService<QuestResetApiFeatures>();
41+
var apiFeatures = ServiceContainer.GetService<QuestResetApiFeatures>();
4042
var sql = ToSql();
41-
var execAsync = apiFeatures.ExecAsync(sql).GetAwaiter().GetResult();
42-
var resultHash = new Hashtable();
43+
var execAsync = await apiFeatures.ExecAsync(sql);
44+
var result = new RestApiExecResponseJsonBody();
4345
try
4446
{
45-
resultHash = JsonConvert.DeserializeObject<Hashtable>(execAsync);
47+
result = JsonConvert.DeserializeObject<RestApiExecResponseJsonBody>(execAsync);
4648
}
4749
catch
4850
{
@@ -52,20 +54,19 @@ private int RestApiExecuteAffrows()
5254
}
5355
}
5456

55-
var ddl = resultHash["ddl"]?.ToString();
56-
return ddl?.ToLower() == "ok" ? 1 : 0;
57+
return result.IsSuccessful ? 1 : 0;
5758
}
5859

5960
public override int ExecuteAffrows()
6061
{
6162
var apiFeatures = ServiceContainer.GetService<QuestResetApiFeatures>();
62-
if (apiFeatures != null && string.IsNullOrWhiteSpace(apiFeatures.BaseAddress))
63+
if (apiFeatures == null || string.IsNullOrWhiteSpace(apiFeatures.BaseAddress))
6364
{
6465
return base.SplitExecuteAffrows(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
6566
_batchParameterLimit > 0 ? _batchParameterLimit : 3000);
6667
}
6768

68-
return RestApiExecuteAffrows();
69+
return RestApiExecuteAffrowsAsync().ConfigureAwait(false).GetAwaiter().GetResult();
6970
}
7071

7172
public override long ExecuteIdentity() => base.SplitExecuteIdentity(
@@ -176,13 +177,13 @@ protected override List<T1> RawExecuteInserted()
176177
public override Task<int> ExecuteAffrowsAsync(CancellationToken cancellationToken = default)
177178
{
178179
var apiFeatures = ServiceContainer.GetService<QuestResetApiFeatures>();
179-
if (apiFeatures != null && string.IsNullOrWhiteSpace(apiFeatures.BaseAddress))
180+
if (apiFeatures == null || string.IsNullOrWhiteSpace(apiFeatures.BaseAddress))
180181
{
181182
return base.SplitExecuteAffrowsAsync(_batchValuesLimit > 0 ? _batchValuesLimit : 5000,
182183
_batchParameterLimit > 0 ? _batchParameterLimit : 3000, cancellationToken);
183184
}
184185

185-
return Task.FromResult(RestApiExecuteAffrows());
186+
return RestApiExecuteAffrowsAsync();
186187
}
187188

188189

0 commit comments

Comments
 (0)