!1989 issue修复:ignore处理json与jsonb类型时,类型零值修正
Merge pull request !1989 from zhangzhixian/issue_fix_json_default
This commit is contained in:
@ -2508,11 +2508,11 @@ Datum GetTypeZeroValue(Form_pg_attribute att_tup)
|
||||
break;
|
||||
}
|
||||
case JSONOID: {
|
||||
result = (Datum)DirectFunctionCall1(json_in, CStringGetDatum("0"));
|
||||
result = (Datum)DirectFunctionCall1(json_in, CStringGetDatum("null"));
|
||||
break;
|
||||
}
|
||||
case JSONBOID: {
|
||||
result = (Datum)DirectFunctionCall1(jsonb_in, CStringGetDatum("0"));
|
||||
result = (Datum)DirectFunctionCall1(jsonb_in, CStringGetDatum("null"));
|
||||
break;
|
||||
}
|
||||
case XMLOID: {
|
||||
|
@ -583,9 +583,9 @@ insert /*+ ignore_error */ into t_json values (null);
|
||||
WARNING: null value in column "c" violates not-null constraint
|
||||
DETAIL: Failing row contains (null).
|
||||
select * from t_json;
|
||||
c
|
||||
---
|
||||
0
|
||||
c
|
||||
------
|
||||
null
|
||||
(1 row)
|
||||
|
||||
insert into t_json values('111');
|
||||
@ -595,10 +595,17 @@ DETAIL: Failing row contains (null).
|
||||
WARNING: null value in column "c" violates not-null constraint
|
||||
DETAIL: Failing row contains (null).
|
||||
select * from t_json;
|
||||
c
|
||||
---
|
||||
0
|
||||
0
|
||||
c
|
||||
------
|
||||
null
|
||||
null
|
||||
(2 rows)
|
||||
|
||||
select * from t_json where c::text = 'null';
|
||||
c
|
||||
------
|
||||
null
|
||||
null
|
||||
(2 rows)
|
||||
|
||||
-- jsonb
|
||||
@ -607,9 +614,9 @@ insert /*+ ignore_error */ into t_jsonb values (null);
|
||||
WARNING: null value in column "c" violates not-null constraint
|
||||
DETAIL: Failing row contains (null).
|
||||
select * from t_jsonb;
|
||||
c
|
||||
---
|
||||
0
|
||||
c
|
||||
------
|
||||
null
|
||||
(1 row)
|
||||
|
||||
insert into t_jsonb values('111');
|
||||
@ -619,10 +626,17 @@ DETAIL: Failing row contains (null).
|
||||
WARNING: null value in column "c" violates not-null constraint
|
||||
DETAIL: Failing row contains (null).
|
||||
select * from t_jsonb;
|
||||
c
|
||||
---
|
||||
0
|
||||
0
|
||||
c
|
||||
------
|
||||
null
|
||||
null
|
||||
(2 rows)
|
||||
|
||||
select * from t_jsonb where c::text = 'null';
|
||||
c
|
||||
------
|
||||
null
|
||||
null
|
||||
(2 rows)
|
||||
|
||||
-- bit
|
||||
|
@ -195,6 +195,7 @@ select * from t_json;
|
||||
insert into t_json values('111');
|
||||
update /*+ ignore_error */ t_json set c = null;
|
||||
select * from t_json;
|
||||
select * from t_json where c::text = 'null';
|
||||
|
||||
-- jsonb
|
||||
create table t_jsonb(c jsonb not null);
|
||||
@ -203,6 +204,7 @@ select * from t_jsonb;
|
||||
insert into t_jsonb values('111');
|
||||
update /*+ ignore_error */ t_jsonb set c = null;
|
||||
select * from t_jsonb;
|
||||
select * from t_jsonb where c::text = 'null';
|
||||
|
||||
-- bit
|
||||
create table t_bit(c bit not null);
|
||||
|
Reference in New Issue
Block a user