mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
人大金仓[SqlServer]
This commit is contained in:
parent
35900da07c
commit
3a805c7f39
@ -106,7 +106,9 @@ namespace SqlSugar
|
||||
new KeyValuePair<string, CSharpDataType>("tsvector",CSharpDataType.@string),
|
||||
new KeyValuePair<string, CSharpDataType>("txid_snapshot",CSharpDataType.@string),
|
||||
new KeyValuePair<string, CSharpDataType>("varcharbyte",CSharpDataType.@string),
|
||||
new KeyValuePair<string, CSharpDataType>("varcharbyte varying",CSharpDataType.@string),
|
||||
new KeyValuePair<string, CSharpDataType>("bpcharbyte",CSharpDataType.@string),
|
||||
new KeyValuePair<string, CSharpDataType>("nvarchar",CSharpDataType.@string),
|
||||
new KeyValuePair<string, CSharpDataType>("uuid",CSharpDataType.Guid),
|
||||
new KeyValuePair<string, CSharpDataType>("xml",CSharpDataType.@string),
|
||||
new KeyValuePair<string, CSharpDataType>("json",CSharpDataType.@string),
|
||||
|
@ -57,6 +57,13 @@ namespace SqlSugar
|
||||
else if (IsSqlServerModel())
|
||||
{
|
||||
sql = sql.Replace("sys_constraint.conkey[1]", "sys_constraint.conkey{{1}}");
|
||||
sql = sql.Replace("UPPER(", "pg_catalog.upper(");
|
||||
sql = sql.Replace("lower(", "pg_catalog.lower(");
|
||||
sql = sql.Replace("NEXTVAL%", "%nextval%");
|
||||
sql = sql.Replace("pcolumn.udt_name", "pcolumn.data_type");
|
||||
sql = sql.Replace("case when pkey.colname = pcolumn.column_name", "case when pkey.colname::text = pcolumn.column_name::text");
|
||||
sql = sql.Replace("pcolumn on pcolumn.table_name = ptables.tablename", "pcolumn on pcolumn.table_name::text = ptables.tablename::text ");
|
||||
sql = sql.Replace("pkey on pcolumn.table_name = pkey.relname", "pkey on pcolumn.table_name::text = pkey.relname::text ");
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
@ -345,6 +352,10 @@ WHERE tgrelid = '" + tableName + "'::regclass");
|
||||
private string GetSchema()
|
||||
{
|
||||
var schema = "public";
|
||||
if (IsSqlServerModel())
|
||||
{
|
||||
schema = "dbo";
|
||||
}
|
||||
if (System.Text.RegularExpressions.Regex.IsMatch(this.Context.CurrentConnectionConfig.ConnectionString.ToLower(), "searchpath="))
|
||||
{
|
||||
var regValue = System.Text.RegularExpressions.Regex.Match(this.Context.CurrentConnectionConfig.ConnectionString.ToLower(), @"searchpath\=(\w+)").Groups[1].Value;
|
||||
@ -406,6 +417,10 @@ WHERE tgrelid = '" + tableName + "'::regclass");
|
||||
public override bool IsAnyTable(string tableName, bool isCache = true)
|
||||
{
|
||||
var sql = $"select count(*) from information_schema.tables where UPPER(table_schema)=UPPER('{GetSchema()}') and UPPER(table_type)=UPPER('BASE TABLE') and UPPER(table_name)=UPPER('{tableName.ToUpper(IsUpper)}')";
|
||||
if (IsSqlServerModel())
|
||||
{
|
||||
sql = $"select count(*) from information_schema.tables where pg_catalog.UPPER(table_name)=pg_catalog.UPPER('{tableName.ToUpper(IsUpper)}')";
|
||||
}
|
||||
return this.Context.Ado.GetInt(sql)>0;
|
||||
}
|
||||
|
||||
@ -429,7 +444,14 @@ WHERE tgrelid = '" + tableName + "'::regclass");
|
||||
}
|
||||
var oldDatabaseName = this.Context.Ado.Connection.Database;
|
||||
var connection = this.Context.CurrentConnectionConfig.ConnectionString;
|
||||
connection = connection.Replace(oldDatabaseName, "test");
|
||||
if (this.Context.CurrentConnectionConfig?.MoreSettings?.DatabaseModel == DbType.SqlServer)
|
||||
{
|
||||
connection = connection.Replace(oldDatabaseName, "master");
|
||||
}
|
||||
else
|
||||
{
|
||||
connection = connection.Replace(oldDatabaseName, "test");
|
||||
}
|
||||
var newDb = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
DbType = this.Context.CurrentConnectionConfig.DbType,
|
||||
|
@ -105,7 +105,7 @@ namespace SqlSugar
|
||||
{
|
||||
sql = " SELECT 'No table' FROM DUAL WHERE 1=2 ";
|
||||
}
|
||||
return new KeyValuePair<string, SugarParameter[]>(sql, parameter);
|
||||
return base.ProcessingEventStartingSQL(sql,parameter);
|
||||
};
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.100" />
|
||||
<PackageReference Include="Oscar.Data.SqlClient" Version="4.0.4" />
|
||||
<PackageReference Include="SqlSugarCore.Dm" Version="8.3.0" />
|
||||
<PackageReference Include="SqlSugarCore.Kdbndp" Version="9.3.6.412" />
|
||||
<PackageReference Include="SqlSugarCore.Kdbndp" Version="9.3.6.618" />
|
||||
<PackageReference Include="System.Data.Common" Version="4.3.0" />
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.7" />
|
||||
<PackageReference Include="System.Data.OleDb" Version="6.0.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user