- 修复 Firebird Embedded 版本系统表 isidentity_type 兼容问题;

This commit is contained in:
28810 2020-10-18 19:23:13 +08:00
parent 0783b432cf
commit b91fe2ca4d
3 changed files with 30 additions and 7 deletions

View File

@ -35,6 +35,29 @@ namespace FreeSql.Firebird
}
}
}
public bool IsFirebird2_5 => ServerVersion.Contains("Firebird 2.5");
public string ServerVersion
{
get
{
if (string.IsNullOrEmpty(_serverVersion) && MasterPool != null)
using (var conn = MasterPool.Get())
{
try
{
_serverVersion = conn.Value.ServerVersion;
}
catch
{
_serverVersion = "3.0.0";
}
}
return _serverVersion;
}
}
string _serverVersion;
public override object AddslashesProcessParam(object param, Type mapType, ColumnInfo mapColumn)
{
if (param == null) return "NULL";

View File

@ -160,7 +160,7 @@ namespace FreeSql.Firebird
tboldname = null; //如果新表已经存在,不走改表名逻辑
//对比字段,只可以修改类型、增加字段、有限的修改字段名;保证安全不删除字段
var sql = _commonUtils.FormatSql(@"
var sql = _commonUtils.FormatSql($@"
select
trim(a.rdb$field_name),
case
@ -176,12 +176,12 @@ case
coalesce((select ' SUB_TYPE ' || rdb$type from rdb$types where b.rdb$field_type = 261 and rdb$type = b.rdb$field_sub_type and rdb$field_name = 'RDB$FIELD_SUB_TYPE' rows 1),'')
end || trim(case when b.rdb$dimensions = 1 then '[]' else '' end),
case when a.rdb$null_flag = 1 then 0 else 1 end,
case when a.rdb$identity_type = 1 then 1 else 0 end,
{((_orm.Ado as FirebirdAdo)?.IsFirebird2_5 == true ? "0" : "case when a.rdb$identity_type = 1 then 1 else 0 end")},
a.rdb$description
from rdb$relation_fields a
inner join rdb$fields b on b.rdb$field_name = a.rdb$field_source
inner join rdb$relations d on d.rdb$relation_name = a.rdb$relation_name
where a.rdb$system_flag = 0 and trim(d.rdb$relation_name) = {0}
where a.rdb$system_flag = 0 and trim(d.rdb$relation_name) = {{0}}
order by a.rdb$relation_name, a.rdb$field_position", tboldname ?? tbname);
var ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
var tbstruct = ds.ToDictionary(a => string.Concat(a[0]), a =>

View File

@ -196,7 +196,7 @@ where rdb$system_flag=0" + (tbname == null ? "" : $" and {(ignoreCase ? "upper(t
}
loc8.Append(")");
sql = string.Format(@"
sql = $@"
select
trim(d.rdb$relation_name),
trim(a.rdb$field_name),
@ -226,15 +226,15 @@ case
coalesce((select ' SUB_TYPE ' || rdb$type from rdb$types where b.rdb$field_type = 261 and rdb$type = b.rdb$field_sub_type and rdb$field_name = 'RDB$FIELD_SUB_TYPE' rows 1),'')
end || trim(case when b.rdb$dimensions = 1 then '[]' else '' end),
case when a.rdb$null_flag = 1 then 0 else 1 end,
case when a.rdb$identity_type = 1 then 1 else 0 end,
{((_orm.Ado as FirebirdAdo)?.IsFirebird2_5 == true ? "0" : "case when a.rdb$identity_type = 1 then 1 else 0 end")},
a.rdb$description,
a.rdb$default_value
from rdb$relation_fields a
inner join rdb$fields b on b.rdb$field_name = a.rdb$field_source
inner join rdb$relations d on d.rdb$relation_name = a.rdb$relation_name
where a.rdb$system_flag = 0 and {0}
where a.rdb$system_flag = 0 and {loc8}
order by a.rdb$relation_name, a.rdb$field_position
", loc8);
";
ds = _orm.Ado.ExecuteArray(CommandType.Text, sql);
if (ds == null) return loc1;