mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 02:29:24 +08:00
修复.NET bool类型转换为pgSql int2
This commit is contained in:
@@ -79,6 +79,25 @@ namespace OpenAuth.App.Test
|
|||||||
ConnectionString = connectionString,
|
ConnectionString = connectionString,
|
||||||
IsAutoCloseConnection = true
|
IsAutoCloseConnection = true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(dbType.Value != SqlSugar.DbType.PostgreSQL){
|
||||||
|
return sqlSugar;
|
||||||
|
}
|
||||||
|
// 配置bool类型转换为smallint
|
||||||
|
sqlSugar.Aop.OnExecutingChangeSql = (sql, parameters) =>
|
||||||
|
{
|
||||||
|
foreach (var param in parameters)
|
||||||
|
{
|
||||||
|
if (param.Value is bool boolValue)
|
||||||
|
{
|
||||||
|
param.DbType = System.Data.DbType.Int16;
|
||||||
|
// 将 bool 转换为 smallint
|
||||||
|
param.Value = boolValue ? (short)1 : (short)0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 返回修改后的 SQL 和参数
|
||||||
|
return new System.Collections.Generic.KeyValuePair<string, SugarParameter[]>(sql, parameters);
|
||||||
|
};
|
||||||
return sqlSugar;
|
return sqlSugar;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -104,13 +104,27 @@ namespace OpenAuth.IdentityServer
|
|||||||
{
|
{
|
||||||
DbType = sugarDbtype.Value,
|
DbType = sugarDbtype.Value,
|
||||||
ConnectionString = connectionString,
|
ConnectionString = connectionString,
|
||||||
IsAutoCloseConnection = true,
|
IsAutoCloseConnection = true
|
||||||
MoreSettings=new ConnMoreSettings() {
|
|
||||||
PgSqlIsAutoToLower = false,//增删查改支持驼峰表
|
|
||||||
PgSqlIsAutoToLowerCodeFirst = false, // 建表建驼峰表。5.1.3.30
|
|
||||||
IsAutoToUpper=false //禁用自动转成大写表
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(sugarDbtype.Value != SqlSugar.DbType.PostgreSQL){
|
||||||
|
return sqlSugar;
|
||||||
|
}
|
||||||
|
// 配置bool类型转换为smallint
|
||||||
|
sqlSugar.Aop.OnExecutingChangeSql = (sql, parameters) =>
|
||||||
|
{
|
||||||
|
foreach (var param in parameters)
|
||||||
|
{
|
||||||
|
if (param.Value is bool boolValue)
|
||||||
|
{
|
||||||
|
param.DbType = System.Data.DbType.Int16;
|
||||||
|
// 将 bool 转换为 smallint
|
||||||
|
param.Value = boolValue ? (short)1 : (short)0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 返回修改后的 SQL 和参数
|
||||||
|
return new System.Collections.Generic.KeyValuePair<string, SugarParameter[]>(sql, parameters);
|
||||||
|
};
|
||||||
return sqlSugar;
|
return sqlSugar;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -111,6 +111,26 @@ namespace OpenAuth.Mvc
|
|||||||
ConnectionString = connectionString,
|
ConnectionString = connectionString,
|
||||||
IsAutoCloseConnection = true
|
IsAutoCloseConnection = true
|
||||||
}, db => { db.Aop.OnLogExecuting = (sql, pars) => { logger.LogInformation(sql); }; });
|
}, db => { db.Aop.OnLogExecuting = (sql, pars) => { logger.LogInformation(sql); }; });
|
||||||
|
|
||||||
|
if(dbType.Value != SqlSugar.DbType.PostgreSQL){
|
||||||
|
return sqlSugar;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 配置bool类型转换为smallint
|
||||||
|
sqlSugar.Aop.OnExecutingChangeSql = (sql, parameters) =>
|
||||||
|
{
|
||||||
|
foreach (var param in parameters)
|
||||||
|
{
|
||||||
|
if (param.Value is bool boolValue)
|
||||||
|
{
|
||||||
|
param.DbType = System.Data.DbType.Int16;
|
||||||
|
// 将 bool 转换为 smallint
|
||||||
|
param.Value = boolValue ? (short)1 : (short)0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 返回修改后的 SQL 和参数
|
||||||
|
return new System.Collections.Generic.KeyValuePair<string, SugarParameter[]>(sql, parameters);
|
||||||
|
};
|
||||||
return sqlSugar;
|
return sqlSugar;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -85,6 +85,26 @@ namespace OpenAuth.Repository.Test
|
|||||||
ConnectionString = connectionString,
|
ConnectionString = connectionString,
|
||||||
IsAutoCloseConnection = true
|
IsAutoCloseConnection = true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(dbType.Value != SqlSugar.DbType.PostgreSQL){
|
||||||
|
return sqlSugar;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 配置bool类型转换为smallint
|
||||||
|
sqlSugar.Aop.OnExecutingChangeSql = (sql, parameters) =>
|
||||||
|
{
|
||||||
|
foreach (var param in parameters)
|
||||||
|
{
|
||||||
|
if (param.Value is bool boolValue)
|
||||||
|
{
|
||||||
|
param.DbType = System.Data.DbType.Int16;
|
||||||
|
// 将 bool 转换为 smallint
|
||||||
|
param.Value = boolValue ? (short)1 : (short)0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 返回修改后的 SQL 和参数
|
||||||
|
return new System.Collections.Generic.KeyValuePair<string, SugarParameter[]>(sql, parameters);
|
||||||
|
};
|
||||||
return sqlSugar;
|
return sqlSugar;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -186,6 +186,26 @@ namespace OpenAuth.WebApi
|
|||||||
ConnectionString = connectionString,
|
ConnectionString = connectionString,
|
||||||
IsAutoCloseConnection = true
|
IsAutoCloseConnection = true
|
||||||
}, db => { db.Aop.OnLogExecuting = (sql, pars) => { logger.LogInformation(sql); }; });
|
}, db => { db.Aop.OnLogExecuting = (sql, pars) => { logger.LogInformation(sql); }; });
|
||||||
|
|
||||||
|
if(dbType.Value != SqlSugar.DbType.PostgreSQL){
|
||||||
|
return sqlSugar;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 配置bool类型转换为smallint
|
||||||
|
sqlSugar.Aop.OnExecutingChangeSql = (sql, parameters) =>
|
||||||
|
{
|
||||||
|
foreach (var param in parameters)
|
||||||
|
{
|
||||||
|
if (param.Value is bool boolValue)
|
||||||
|
{
|
||||||
|
param.DbType = System.Data.DbType.Int16;
|
||||||
|
// 将 bool 转换为 smallint
|
||||||
|
param.Value = boolValue ? (short)1 : (short)0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 返回修改后的 SQL 和参数
|
||||||
|
return new System.Collections.Generic.KeyValuePair<string, SugarParameter[]>(sql, parameters);
|
||||||
|
};
|
||||||
return sqlSugar;
|
return sqlSugar;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user