提交 ffd27af3 编写于 作者: B Boris Djurdjevic

refactor

上级 fd3cc1d5
......@@ -3,6 +3,12 @@
👍 First off, thanks for taking the time to contribute! 👍<br>
Working together we can make a better tool for everyone.
## Code of Conduct
This project and everyone participating in it is governed by the [Code of Conduct](CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code.
By making a PullRequest Contributor assigns the copyright to the project owner.
### Where do I go from here?
If you've noticed a bug or have an idea about new feature you can open a issue.
......
......@@ -3,8 +3,6 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.Caching.Memory;
using Npgsql;
using NpgsqlTypes;
using System;
using System.Collections.Generic;
using System.Diagnostics;
......@@ -225,7 +223,6 @@ public class EFCoreBulkTest
// SET GLOBAL local_infile = true;
// -- otherwise exception: "Loading local data is disabled; this must be enabled on both the client and server sides"
// -- For client side connection string is already set with: "AllowLoadLocalInfile=true"
// https://stackoverflow.com/questions/59993844/error-loading-local-data-is-disabled-this-must-be-enabled-on-both-the-client
public void InsertTestMySQL(DbServerType dbServer)
{
ContextUtil.DbServer = dbServer;
......@@ -313,7 +310,7 @@ public class EFCoreBulkTest
entities5.Add(new Item { ItemId = 16, Name = "Name 16", Description = "info 16" }); // when BulkSaveChanges with Upsert 'ItemId' has to be set(EX.My1), and with Insert only it skips one number, Id becomes 17 instead of 16
context.AddRange(entities5);
context.BulkSaveChanges();
Assert.Equal(16, entities5[1].ItemId);
Assert.Equal(16, entities5[1].ItemId); // TODO Check Id is 2 instead of 16
Assert.Equal("info 16", context.Items.Where(a => a.Name == "Name 16").AsNoTracking().FirstOrDefault()?.Description);
//EX.My1: "The property 'Item.ItemId' has a temporary value while attempting to change the entity's state to 'Unchanged'.
......
......@@ -231,12 +231,12 @@ public class SqlQueryBuilderPostgreSql : SqlAdapters.QueryBuilderExtensions
var schemaFormated = tableInfo.Schema == null ? "" : $@"""{tableInfo.Schema}"".";
var fullTableNameFormated = $@"{schemaFormated}""{tableName}""";
var uniqueConstrainName = GetUniqueConstrainName(tableInfo);
var uniqueColumnNames = tableInfo.PrimaryKeysPropertyColumnNameDict.Values.ToList();
var uniqueColumnNamesDash = string.Join("_", uniqueColumnNames);
var uniqueColumnNamesFormated = @"""" + string.Join(@""", """, uniqueColumnNames) + @"""";
var schemaDash = tableInfo.Schema == null ? "" : $"{tableInfo.Schema}_";
var q = $@"CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS ""tempUniqueIndex_{schemaDash}{tableName}_{uniqueColumnNamesDash}"" " +
var q = $@"CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS ""{uniqueConstrainName}"" " +
$@"ON {fullTableNameFormated} ({uniqueColumnNamesFormated})";
return q;
}
......@@ -251,10 +251,7 @@ public class SqlQueryBuilderPostgreSql : SqlAdapters.QueryBuilderExtensions
var schemaFormated = tableInfo.Schema == null ? "" : $@"""{tableInfo.Schema}"".";
var fullTableNameFormated = $@"{schemaFormated}""{tableName}""";
var uniqueColumnNames = tableInfo.PrimaryKeysPropertyColumnNameDict.Values.ToList();
var uniqueColumnNamesDash = string.Join("_", uniqueColumnNames);
var schemaDash = tableInfo.Schema == null ? "" : $"{tableInfo.Schema}_";
var uniqueConstrainName = $"tempUniqueIndex_{schemaDash}{tableName}_{uniqueColumnNamesDash}";
var uniqueConstrainName = GetUniqueConstrainName(tableInfo);
var q = $@"ALTER TABLE {fullTableNameFormated} " +
$@"ADD CONSTRAINT ""{uniqueConstrainName}"" " +
......@@ -272,10 +269,7 @@ public class SqlQueryBuilderPostgreSql : SqlAdapters.QueryBuilderExtensions
var schemaFormated = tableInfo.Schema == null ? "" : $@"""{tableInfo.Schema}"".";
var fullTableNameFormated = $@"{schemaFormated}""{tableName}""";
var uniqueColumnNames = tableInfo.PrimaryKeysPropertyColumnNameDict.Values.ToList();
var uniqueColumnNamesDash = string.Join("_", uniqueColumnNames);
var schemaDash = tableInfo.Schema == null ? "" : $"{tableInfo.Schema}_";
var uniqueConstrainName = $"tempUniqueIndex_{schemaDash}{tableName}_{uniqueColumnNamesDash}";
var uniqueConstrainName = GetUniqueConstrainName(tableInfo);
var q = $@"ALTER TABLE {fullTableNameFormated} " +
$@"DROP CONSTRAINT ""{uniqueConstrainName}"";";
......
......@@ -18,6 +18,7 @@ OpenSource needs funding, so even for free usage if you can please consider maki
## Contributing
Please read [CONTRIBUTING](CONTRIBUTING.md) for details on code of conduct, and the process for submitting pull requests.<br>
When opening issues do write detailed explanation of the problem or feature with reproducible example.<br>
## Description
Supported databases:<br>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册