From 0ac81caaece9316fe0978e8403436f7de0fd5869 Mon Sep 17 00:00:00 2001
From: Daily <963922242@qq.com>
Date: Sat, 23 Mar 2024 09:09:56 +0800
Subject: [PATCH 1/8] =?UTF-8?q?=E4=BC=98=E5=8C=96QuestDb=20BulkCopy?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=B9=B6=E9=87=8D=E5=91=BD=E5=90=8D?=
=?UTF-8?q?=E4=B8=BA=EF=BC=9AExecuteQuestDbBulkCopy?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../QuestDbGlobalExtensions.cs | 96 +++++++++----------
1 file changed, 47 insertions(+), 49 deletions(-)
diff --git a/Providers/FreeSql.Provider.QuestDb/QuestDbGlobalExtensions.cs b/Providers/FreeSql.Provider.QuestDb/QuestDbGlobalExtensions.cs
index d47197c9a..79d395bb2 100644
--- a/Providers/FreeSql.Provider.QuestDb/QuestDbGlobalExtensions.cs
+++ b/Providers/FreeSql.Provider.QuestDb/QuestDbGlobalExtensions.cs
@@ -31,12 +31,12 @@ public static partial class QuestDbGlobalExtensions
///
///
public static string FormatQuestDb(this string that, params object[] args) =>
- _QuestDbAdo.Addslashes(that, args);
+ _questDbAdo.Addslashes(that, args);
- static QuestDbAdo _QuestDbAdo = new QuestDbAdo();
+ private static readonly QuestDbAdo _questDbAdo = new QuestDbAdo();
- public static FreeSqlBuilder UseQuestDbRestAPI(this FreeSqlBuilder buider, string host, string username = "",
- string password = "") => RestAPIExtension.UseQuestDbRestAPI(buider, host, username, password);
+ public static FreeSqlBuilder UseQuestDbRestAPI(this FreeSqlBuilder build, string host, string username = "",
+ string password = "") => RestAPIExtension.UseQuestDbRestAPI(build, host, username, password);
///
/// 对于多个时间序列存储在同一个表中的场景,根据时间戳检索给定键或键组合的最新项。
@@ -53,6 +53,7 @@ public static ISelect LatestOn(this ISelect select, Expression
LatestOnExtension.InternelImpl(timestamp, partition);
return select;
}
+
///
/// 对于多个时间序列存储在同一个表中的场景,根据时间戳检索给定键或键组合的最新项。
///
@@ -113,13 +114,15 @@ public static ISelect LatestOn(this ISelec
/// 单位
/// 对准日历
///
- public static ISelect SampleBy(this ISelect select, double time, SampleUnit unit, bool alignToCalendar = false)
+ public static ISelect SampleBy(this ISelect select, double time, SampleUnit unit,
+ bool alignToCalendar = false)
{
SampleByExtension.IsExistence.Value = true;
var samoleByTemple = $"{Environment.NewLine}SAMPLE BY {{0}}{{1}} {{2}}";
string alignToCalendarTemple = "";
if (alignToCalendar) alignToCalendarTemple = "ALIGN TO CALENDAR ";
- SampleByExtension.SamoleByString.Value = string.Format(samoleByTemple, time.ToString(), (char)unit, alignToCalendarTemple);
+ SampleByExtension.SamoleByString.Value =
+ string.Format(samoleByTemple, time.ToString(), (char)unit, alignToCalendarTemple);
return select;
}
@@ -156,23 +159,25 @@ private static List SplitByLine(string text)
///
/// 导入时,时间格式 默认:yyyy/M/d H:mm:ss
///
- public static async Task ExecuteBulkCopyAsync(this IInsert that,string dateFormat = "yyyy/M/d H:mm:ss") where T : class
+ public static async Task ExecuteQuestDbBulkCopyAsync(this IInsert that,
+ string dateFormat = "yyyy/M/d H:mm:ss") where T : class
{
//思路:通过提供的RestAPI imp,实现快速复制
if (string.IsNullOrWhiteSpace(RestAPIExtension.BaseUrl))
{
- throw new Exception("BulkCopy功能需要启用RestAPI,启用方式:new FreeSqlBuilder().UseQuestDbRestAPI(\"localhost:9000\", \"username\", \"password\")");
+ throw new Exception(
+ "BulkCopy功能需要启用RestAPI,启用方式:new FreeSqlBuilder().UseQuestDbRestAPI(\"localhost:9000\", \"username\", \"password\")");
}
+
var result = 0;
- var fileName = $"{Guid.NewGuid()}.csv";
- var filePath = Path.Combine(AppContext.BaseDirectory, fileName);
+
try
{
var client = QuestDbContainer.GetService().CreateClient();
var boundary = "---------------" + DateTime.Now.Ticks.ToString("x");
var list = new List();
var insert = that as QuestDbInsert;
- var name = insert.InternalTableRuleInvoke(); //获取表名
+ var name = insert.InternalTableRuleInvoke(); //获取表名
insert.InternalOrm.DbFirst.GetTableByName(name).Columns.ForEach(d =>
{
if (d.DbTypeText == "TIMESTAMP")
@@ -181,7 +186,7 @@ public static async Task ExecuteBulkCopyAsync(this IInsert that,strin
{
{ "name", d.Name },
{ "type", d.DbTypeText },
- { "pattern", dateFormat}
+ { "pattern", dateFormat }
});
}
else
@@ -194,34 +199,37 @@ public static async Task ExecuteBulkCopyAsync(this IInsert that,strin
}
});
var schema = JsonConvert.SerializeObject(list);
- //写入CSV文件
- using (var writer = new StreamWriter(filePath))
- using (var csv = new CsvWriter(writer, CultureInfo.CurrentCulture))
+ using (MemoryStream stream = new MemoryStream())
{
- await csv.WriteRecordsAsync(insert._source);
- }
+ //写入CSV文件
+ using (var writer = new StreamWriter(stream))
+ using (var csv = new CsvWriter(writer, CultureInfo.CurrentCulture))
+ {
+ await csv.WriteRecordsAsync(insert._source);
+ }
- var httpContent = new MultipartFormDataContent(boundary);
- if (!string.IsNullOrWhiteSpace(RestAPIExtension.authorization))
- client.DefaultRequestHeaders.Add("Authorization", RestAPIExtension.authorization);
- httpContent.Add(new StringContent(schema), "schema");
- httpContent.Add(new ByteArrayContent(File.ReadAllBytes(filePath)), "data");
- //boundary带双引号 可能导致服务器错误情况
- httpContent.Headers.Remove("Content-Type");
- httpContent.Headers.TryAddWithoutValidation("Content-Type",
- "multipart/form-data; boundary=" + boundary);
- var httpResponseMessage =
- await client.PostAsync($"{RestAPIExtension.BaseUrl}/imp?name={name}", httpContent);
- var readAsStringAsync = await httpResponseMessage.Content.ReadAsStringAsync();
- var splitByLine = SplitByLine(readAsStringAsync);
- foreach (var s in splitByLine)
- {
- if (s.Contains("Rows"))
+ var httpContent = new MultipartFormDataContent(boundary);
+ if (!string.IsNullOrWhiteSpace(RestAPIExtension.authorization))
+ client.DefaultRequestHeaders.Add("Authorization", RestAPIExtension.authorization);
+ httpContent.Add(new StringContent(schema), "schema");
+ httpContent.Add(new ByteArrayContent(stream.ToArray()), "data");
+ //boundary带双引号 可能导致服务器错误情况
+ httpContent.Headers.Remove("Content-Type");
+ httpContent.Headers.TryAddWithoutValidation("Content-Type",
+ "multipart/form-data; boundary=" + boundary);
+ var httpResponseMessage =
+ await client.PostAsync($"{RestAPIExtension.BaseUrl}/imp?name={name}", httpContent);
+ var readAsStringAsync = await httpResponseMessage.Content.ReadAsStringAsync();
+ var splitByLine = SplitByLine(readAsStringAsync);
+ foreach (var s in splitByLine)
{
- var strings = s.Split('|');
- if (strings[1].Trim() == "Rows imported")
+ if (s.Contains("Rows"))
{
- result = Convert.ToInt32(strings[2].Trim());
+ var strings = s.Split('|');
+ if (strings[1].Trim() == "Rows imported")
+ {
+ result = Convert.ToInt32(strings[2].Trim());
+ }
}
}
}
@@ -230,17 +238,6 @@ public static async Task ExecuteBulkCopyAsync(this IInsert that,strin
{
throw e;
}
- finally
- {
- try
- {
- File.Delete(filePath);
- }
- catch
- {
- // ignored
- }
- }
return result;
}
@@ -252,9 +249,9 @@ public static async Task ExecuteBulkCopyAsync(this IInsert that,strin
///
/// 导入时,时间格式 默认:yyyy/M/d H:mm:ss
///
- public static int ExecuteBulkCopy(this IInsert insert,string dateFormat = "yyyy/M/d H:mm:ss") where T : class
+ public static int ExecuteBulkCopy(this IInsert insert, string dateFormat = "yyyy/M/d H:mm:ss") where T : class
{
- return ExecuteBulkCopyAsync(insert,dateFormat).ConfigureAwait(false).GetAwaiter().GetResult();
+ return ExecuteQuestDbBulkCopyAsync(insert, dateFormat).ConfigureAwait(false).GetAwaiter().GetResult();
}
}
@@ -344,6 +341,7 @@ internal static FreeSqlBuilder UseQuestDbRestAPI(FreeSqlBuilder buider, string h
var base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}"));
authorization = $"Basic {base64}";
}
+
//RestApi需要无参数
buider.UseNoneCommandParameter(true);
return buider;
From 643705918534bda90ab969fb7bc5d8287daf09ed Mon Sep 17 00:00:00 2001
From: Daily <963922242@qq.com>
Date: Sat, 23 Mar 2024 09:10:31 +0800
Subject: [PATCH 2/8] =?UTF-8?q?Clickhouse=20BulkCopy=E5=B9=B6=E9=87=8D?=
=?UTF-8?q?=E5=91=BD=E5=90=8D=E4=B8=BA=EF=BC=9AExecuteClickHouseBulkCopy?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Providers/FreeSql.Provider.ClickHouse/ClickHouseExtensions.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Providers/FreeSql.Provider.ClickHouse/ClickHouseExtensions.cs b/Providers/FreeSql.Provider.ClickHouse/ClickHouseExtensions.cs
index 36428c072..11c472857 100644
--- a/Providers/FreeSql.Provider.ClickHouse/ClickHouseExtensions.cs
+++ b/Providers/FreeSql.Provider.ClickHouse/ClickHouseExtensions.cs
@@ -66,7 +66,7 @@ public static ISelect Sample(this ISelect that, decimal k, int n, decim
///
///
///
- public static async Task ExecuteBulkCopyAsync(this IInsert that) where T : class
+ public static async Task ExecuteClickHouseBulkCopyAsync(this IInsert that) where T : class
{
try
{
@@ -89,6 +89,6 @@ public static async Task ExecuteBulkCopyAsync(this IInsert that) wher
///
public static int ExecuteBulkCopy(this IInsert insert) where T : class
{
- return ExecuteBulkCopyAsync(insert).ConfigureAwait(false).GetAwaiter().GetResult();
+ return ExecuteClickHouseBulkCopyAsync(insert).ConfigureAwait(false).GetAwaiter().GetResult();
}
}
From d79d1ba628577b87f8e1ef59226889bc4e82f427 Mon Sep 17 00:00:00 2001
From: Daily <963922242@qq.com>
Date: Sat, 23 Mar 2024 09:11:03 +0800
Subject: [PATCH 3/8] =?UTF-8?q?=E6=9B=B4=E6=94=B9ClickHouse=E5=8D=95?=
=?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FreeSql.Tests/FreeSql.Tests/ClickHouse/ClickHouseTest3.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/FreeSql.Tests/FreeSql.Tests/ClickHouse/ClickHouseTest3.cs b/FreeSql.Tests/FreeSql.Tests/ClickHouse/ClickHouseTest3.cs
index b3fbd72db..44b8940dc 100644
--- a/FreeSql.Tests/FreeSql.Tests/ClickHouse/ClickHouseTest3.cs
+++ b/FreeSql.Tests/FreeSql.Tests/ClickHouse/ClickHouseTest3.cs
@@ -282,7 +282,7 @@ public async Task UriStringIsTooLongTest()
//单个插入报错
await _fsql.Insert(t).ExecuteAffrowsAsync();
- // await _fsql.Insert(t).ExecuteBulkCopyAsync();
+ // await _fsql.Insert(t).ExecuteQuestBulkCopyAsync();
}
@@ -304,7 +304,7 @@ public async Task TestBulkCopySingle()
//单个插入报错
await _fsql.Insert(t).ExecuteAffrowsAsync();
- await _fsql.Insert(t).ExecuteBulkCopyAsync();
+ await _fsql.Insert(t).ExecuteClickHouseBulkCopyAsync();
_fsql.Insert(t).ExecuteBulkCopy();
}
@@ -333,7 +333,7 @@ public async Task TestBulkCopyMany()
await _fsql.Insert(t).ExecuteAffrowsAsync();
//BulkCopy不会报错
- await _fsql.Insert(t).ExecuteBulkCopyAsync();
+ await _fsql.Insert(t).ExecuteClickHouseBulkCopyAsync();
_fsql.Insert(t).ExecuteBulkCopy();
}
From 90ca205f321d201b114d0f8ea4ac38813e01d105 Mon Sep 17 00:00:00 2001
From: Daily <963922242@qq.com>
Date: Sat, 23 Mar 2024 09:11:39 +0800
Subject: [PATCH 4/8] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E6=B5=8B=E8=AF=95QuestDb?=
=?UTF-8?q?=20BulkCopy?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../FreeSql.Tests/QuestDb/Crud/QuestDbTestInsertAndUpdate.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/FreeSql.Tests/FreeSql.Tests/QuestDb/Crud/QuestDbTestInsertAndUpdate.cs b/FreeSql.Tests/FreeSql.Tests/QuestDb/Crud/QuestDbTestInsertAndUpdate.cs
index cde036015..06508c5a7 100644
--- a/FreeSql.Tests/FreeSql.Tests/QuestDb/Crud/QuestDbTestInsertAndUpdate.cs
+++ b/FreeSql.Tests/FreeSql.Tests/QuestDb/Crud/QuestDbTestInsertAndUpdate.cs
@@ -223,7 +223,8 @@ public async Task TestSqlBulkCopy()
NameUpdate = "NameUpdate"
});
}
- var result = await restFsql.Insert(list).ExecuteBulkCopyAsync();
+
+ var result = await restFsql.Insert(list).ExecuteQuestBulkCopyAsync();
Assert.True(result > 0);
}
From 8b34ff533e287ddde226b341143b8d1cd8fafa22 Mon Sep 17 00:00:00 2001
From: Daily <963922242@qq.com>
Date: Sat, 23 Mar 2024 09:12:06 +0800
Subject: [PATCH 5/8] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=AA=8C=E8=AF=81QuestDb?=
=?UTF-8?q?=20Issue?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../QuestDb/QuestDbIssue/QuestDbIssue.cs | 41 +++++++++++++++++++
.../FreeSql.Tests/QuestDb/QuestDbTest.cs | 10 +++--
2 files changed, 48 insertions(+), 3 deletions(-)
create mode 100644 FreeSql.Tests/FreeSql.Tests/QuestDb/QuestDbIssue/QuestDbIssue.cs
diff --git a/FreeSql.Tests/FreeSql.Tests/QuestDb/QuestDbIssue/QuestDbIssue.cs b/FreeSql.Tests/FreeSql.Tests/QuestDb/QuestDbIssue/QuestDbIssue.cs
new file mode 100644
index 000000000..1ad03757f
--- /dev/null
+++ b/FreeSql.Tests/FreeSql.Tests/QuestDb/QuestDbIssue/QuestDbIssue.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace FreeSql.Tests.QuestDb.QuestDbIssue
+{
+ internal class QuestDbIssue : QuestDbTest
+ {
+
+
+ [Fact]
+ public void Issue1757()
+ {
+ restFsql.CodeFirst.SyncStructure();
+ var count= fsql.Insert(new List() {
+ new Test0111(){
+ CreateTime=DateTime.Now,
+ CustomId=2, Name="test111",
+ Price=2,
+ Value=2 }
+ }).ExecuteQuestBulkCopyAsync();
+
+ var list = fsql.Select().ToList();
+ }
+ }
+
+ public class Test0111
+ {
+ public long Id { get; set; }
+
+ public string Name { get; set; }
+ public decimal Price { get; set; }
+ public DateTime CreateTime { get; set; }
+ public long CustomId { get; set; }
+
+ public double Value { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/FreeSql.Tests/FreeSql.Tests/QuestDb/QuestDbTest.cs b/FreeSql.Tests/FreeSql.Tests/QuestDb/QuestDbTest.cs
index 69072f412..a1fb83c80 100644
--- a/FreeSql.Tests/FreeSql.Tests/QuestDb/QuestDbTest.cs
+++ b/FreeSql.Tests/FreeSql.Tests/QuestDb/QuestDbTest.cs
@@ -4,6 +4,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Xunit;
namespace FreeSql.Tests.QuestDb
{
@@ -11,16 +12,19 @@ public class QuestDbTest
{
public static IFreeSql fsql = new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.QuestDb,
- @"host=192.168.0.36;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
+ @"host=192.168.1.114;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
.UseMonitorCommand(cmd => Debug.WriteLine($"Sql:{cmd.CommandText}")) //监听SQL语句
.UseNoneCommandParameter(true)
.Build();
public static IFreeSql restFsql = new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.QuestDb,
- @"host=192.168.0.36;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
+ @"host=192.168.1.114;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;")
.UseMonitorCommand(cmd => Debug.WriteLine($"Sql:{cmd.CommandText}")) //监听SQL语句
- .UseQuestDbRestAPI("192.168.0.36:9001", "admin", "ushahL(aer2r")
+ .UseQuestDbRestAPI("192.168.1.114:9000")
.Build();
+
}
+
+
}
\ No newline at end of file
From 8b152228b4ca60deeb561daaa8f45266dd00573a Mon Sep 17 00:00:00 2001
From: Daily <963922242@qq.com>
Date: Sat, 23 Mar 2024 09:19:44 +0800
Subject: [PATCH 6/8] =?UTF-8?q?Clickhouse=20BulkCopy=E5=B9=B6=E9=87=8D?=
=?UTF-8?q?=E5=91=BD=E5=90=8D=E4=B8=BA=EF=BC=9AExecuteClickHouseBulkCopy?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Providers/FreeSql.Provider.ClickHouse/ClickHouseExtensions.cs | 2 +-
Providers/FreeSql.Provider.QuestDb/QuestDbGlobalExtensions.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Providers/FreeSql.Provider.ClickHouse/ClickHouseExtensions.cs b/Providers/FreeSql.Provider.ClickHouse/ClickHouseExtensions.cs
index 11c472857..2e4d0a7fc 100644
--- a/Providers/FreeSql.Provider.ClickHouse/ClickHouseExtensions.cs
+++ b/Providers/FreeSql.Provider.ClickHouse/ClickHouseExtensions.cs
@@ -87,7 +87,7 @@ public static async Task ExecuteClickHouseBulkCopyAsync(this IInsert
///
///
///
- public static int ExecuteBulkCopy(this IInsert insert) where T : class
+ public static int ExecuteClickHouseBulkCopy(this IInsert insert) where T : class
{
return ExecuteClickHouseBulkCopyAsync(insert).ConfigureAwait(false).GetAwaiter().GetResult();
}
diff --git a/Providers/FreeSql.Provider.QuestDb/QuestDbGlobalExtensions.cs b/Providers/FreeSql.Provider.QuestDb/QuestDbGlobalExtensions.cs
index 79d395bb2..a047356a0 100644
--- a/Providers/FreeSql.Provider.QuestDb/QuestDbGlobalExtensions.cs
+++ b/Providers/FreeSql.Provider.QuestDb/QuestDbGlobalExtensions.cs
@@ -249,7 +249,7 @@ public static async Task ExecuteQuestDbBulkCopyAsync(this IInsert tha
///
/// 导入时,时间格式 默认:yyyy/M/d H:mm:ss
///
- public static int ExecuteBulkCopy(this IInsert insert, string dateFormat = "yyyy/M/d H:mm:ss") where T : class
+ public static int ExecuteQuestDbBulkCopy(this IInsert insert, string dateFormat = "yyyy/M/d H:mm:ss") where T : class
{
return ExecuteQuestDbBulkCopyAsync(insert, dateFormat).ConfigureAwait(false).GetAwaiter().GetResult();
}
From b3480cc7ed802d13f88fa5318b7b1116c149713c Mon Sep 17 00:00:00 2001
From: Daily <963922242@qq.com>
Date: Sat, 23 Mar 2024 09:20:07 +0800
Subject: [PATCH 7/8] =?UTF-8?q?=E5=AE=8C=E5=96=84Clickhouse=E5=8D=95?=
=?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FreeSql.Tests/FreeSql.Tests/ClickHouse/ClickHouseTest3.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/FreeSql.Tests/FreeSql.Tests/ClickHouse/ClickHouseTest3.cs b/FreeSql.Tests/FreeSql.Tests/ClickHouse/ClickHouseTest3.cs
index 44b8940dc..3ae9c22c4 100644
--- a/FreeSql.Tests/FreeSql.Tests/ClickHouse/ClickHouseTest3.cs
+++ b/FreeSql.Tests/FreeSql.Tests/ClickHouse/ClickHouseTest3.cs
@@ -306,7 +306,7 @@ public async Task TestBulkCopySingle()
await _fsql.Insert(t).ExecuteClickHouseBulkCopyAsync();
- _fsql.Insert(t).ExecuteBulkCopy();
+ _fsql.Insert(t).ExecuteClickHouseBulkCopy();
}
///
@@ -335,7 +335,7 @@ public async Task TestBulkCopyMany()
//BulkCopy不会报错
await _fsql.Insert(t).ExecuteClickHouseBulkCopyAsync();
- _fsql.Insert(t).ExecuteBulkCopy();
+ _fsql.Insert(t).ExecuteClickHouseBulkCopy();
}
}
From 6861f326fd9e5291384e2887b09efcb36434d2c5 Mon Sep 17 00:00:00 2001
From: Daily <963922242@qq.com>
Date: Sat, 23 Mar 2024 09:20:30 +0800
Subject: [PATCH 8/8] =?UTF-8?q?=E5=AE=8C=E5=96=84QuestDb=E5=8D=95=E5=85=83?=
=?UTF-8?q?=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Crud/QuestDbTestInsertAndUpdate.cs | 2 +-
.../QuestDb/QuestDbIssue/QuestDbIssue.cs | 62 +++++++++++++++----
2 files changed, 51 insertions(+), 13 deletions(-)
diff --git a/FreeSql.Tests/FreeSql.Tests/QuestDb/Crud/QuestDbTestInsertAndUpdate.cs b/FreeSql.Tests/FreeSql.Tests/QuestDb/Crud/QuestDbTestInsertAndUpdate.cs
index 06508c5a7..15cebad3e 100644
--- a/FreeSql.Tests/FreeSql.Tests/QuestDb/Crud/QuestDbTestInsertAndUpdate.cs
+++ b/FreeSql.Tests/FreeSql.Tests/QuestDb/Crud/QuestDbTestInsertAndUpdate.cs
@@ -224,7 +224,7 @@ public async Task TestSqlBulkCopy()
});
}
- var result = await restFsql.Insert(list).ExecuteQuestBulkCopyAsync();
+ var result = await restFsql.Insert(list).ExecuteQuestDbBulkCopyAsync();
Assert.True(result > 0);
}
diff --git a/FreeSql.Tests/FreeSql.Tests/QuestDb/QuestDbIssue/QuestDbIssue.cs b/FreeSql.Tests/FreeSql.Tests/QuestDb/QuestDbIssue/QuestDbIssue.cs
index 1ad03757f..68a0ba0aa 100644
--- a/FreeSql.Tests/FreeSql.Tests/QuestDb/QuestDbIssue/QuestDbIssue.cs
+++ b/FreeSql.Tests/FreeSql.Tests/QuestDb/QuestDbIssue/QuestDbIssue.cs
@@ -7,21 +7,59 @@
namespace FreeSql.Tests.QuestDb.QuestDbIssue
{
- internal class QuestDbIssue : QuestDbTest
+ public class QuestDbIssue : QuestDbTest
{
+ [Fact]
+ public void Issue1757()
+ {
+ restFsql.CodeFirst.SyncStructure();
+ var count = fsql.Insert(new List()
+ {
+ new()
+ {
+ CreateTime = DateTime.Now,
+ CustomId = 3, Name = "test333",
+ Price = 3,
+ Value = 3
+ }
+ }).ExecuteQuestDbBulkCopy();
+
+ Assert.True(count > 0);
+
+ var list = fsql.Select().ToList();
+ }
[Fact]
- public void Issue1757()
+ public void Issue1757Many()
{
restFsql.CodeFirst.SyncStructure();
- var count= fsql.Insert(new List() {
- new Test0111(){
- CreateTime=DateTime.Now,
- CustomId=2, Name="test111",
- Price=2,
- Value=2 }
- }).ExecuteQuestBulkCopyAsync();
+ var count = fsql.Insert(new List()
+ {
+ new()
+ {
+ CreateTime = DateTime.Now,
+ CustomId = 4, Name = "test444",
+ Price = 4,
+ Value = 4
+ },
+ new()
+ {
+ CreateTime = DateTime.Now,
+ CustomId = 5, Name = "test555",
+ Price = 5,
+ Value = 5
+ },
+ new()
+ {
+ CreateTime = DateTime.Now,
+ CustomId = 6, Name = "test666",
+ Price = 6,
+ Value = 6
+ }
+ }).ExecuteQuestDbBulkCopy();
+
+ Assert.True(count > 0);
var list = fsql.Select().ToList();
}
@@ -32,10 +70,10 @@ public class Test0111
public long Id { get; set; }
public string Name { get; set; }
- public decimal Price { get; set; }
- public DateTime CreateTime { get; set; }
+ public decimal Price { get; set; }
+ public DateTime CreateTime { get; set; }
public long CustomId { get; set; }
- public double Value { get; set; }
+ public double Value { get; set; }
}
}
\ No newline at end of file