column “is_delete” is of type boolean but expression is of type integer

1.1、前置条件

目标库:V9.0.5.1

源库:MySQL

1.2、问题描述

insert
into
gov_service_hall.department (id,
dept_name,
code,
order_id,
add_time,
update_time,
is_delete,
master,
master_tel,
charger_user_ids,
external_dep_id,
external_dep_name,
dept_level1,
dept_level2)
values (1,
'领导',
'222',
1,
'2021-03-08 00:00:00',
'2022-10-19 10:17:43',
0,
'',
'',
'',
'dept000070006',
'领导',
'0',
'0/1');

报错:column “is_delete” is of type boolean but expression is of type integer

1.3、操作步骤

-- 1、查询已有的隐式转换
select
OID,castsource ,(select typname from pg_type where oid = castsource) as castsourcename ,
casttarget , ( select typname from pg_type where oid = casttarget) as casttargetname ,
castfunc , ( select proname from pg_proc where oid = castfunc ) as castfuncname,
castcontext ,
CASE castcontext::text
WHEN 'e'::text THEN '禁止'::text
WHEN 'a'::text THEN '赋值'::text
WHEN 'i'::text THEN '全部'::text
END
from pg_cast where
castsource in( select oid from pg_type
where typname like '%int%' )
and casttarget in( select oid from pg_type
where typname like '%bool%' );
-- 2、结果,无效隐式转换
10034 23 int4 16 bool 2557 bool e 禁止
-- 3、修改这个为全部
update pg_cast set castcontext='i' where oid =10034

[!NOTE]

赋值:需要向数据库字段类型方向类型转换,比如这是的数据库类型是bool,需要开启integer到bool的隐式转换

1.4、预期结果

SQL可以正常执行,数据插入成功

1.5、异常处理

暂未发现相关异常场景

1.6、回滚方案

update pg_cast set castcontext='e' where oid =10034

1.7、典型场景示例

用户在使用源库MySQL时,使用了很多不同类型数据比较、赋值等