diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/DbBind/KdbndpBind.cs b/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/DbBind/KdbndpBind.cs index ce815bad8..e870c7d2c 100644 --- a/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/DbBind/KdbndpBind.cs +++ b/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/DbBind/KdbndpBind.cs @@ -106,7 +106,9 @@ namespace SqlSugar new KeyValuePair("tsvector",CSharpDataType.@string), new KeyValuePair("txid_snapshot",CSharpDataType.@string), new KeyValuePair("varcharbyte",CSharpDataType.@string), + new KeyValuePair("varcharbyte varying",CSharpDataType.@string), new KeyValuePair("bpcharbyte",CSharpDataType.@string), + new KeyValuePair("nvarchar",CSharpDataType.@string), new KeyValuePair("uuid",CSharpDataType.Guid), new KeyValuePair("xml",CSharpDataType.@string), new KeyValuePair("json",CSharpDataType.@string), diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs b/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs index b4e1084f9..4d25b394b 100644 --- a/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSugar/Realization/Kdbndp/DbMaintenance/KdbndpDbMaintenance.cs @@ -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, diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/Oracle/OracleProvider.cs b/Src/Asp.NetCore2/SqlSugar/Realization/Oracle/OracleProvider.cs index 827cb0f76..81ffc4e16 100644 --- a/Src/Asp.NetCore2/SqlSugar/Realization/Oracle/OracleProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Realization/Oracle/OracleProvider.cs @@ -105,7 +105,7 @@ namespace SqlSugar { sql = " SELECT 'No table' FROM DUAL WHERE 1=2 "; } - return new KeyValuePair(sql, parameter); + return base.ProcessingEventStartingSQL(sql,parameter); }; diff --git a/Src/Asp.NetCore2/SqlSugar/SqlSugar.csproj b/Src/Asp.NetCore2/SqlSugar/SqlSugar.csproj index 271aa0336..4a41d2b53 100644 --- a/Src/Asp.NetCore2/SqlSugar/SqlSugar.csproj +++ b/Src/Asp.NetCore2/SqlSugar/SqlSugar.csproj @@ -27,7 +27,7 @@ - +