2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-23 20:41:55 +01:00
"""
ID : issue - 4773
ISSUE : 4773
TITLE : Regression : NOT NULL constraint , declared in domain , does not work
DESCRIPTION :
JIRA : CORE - 4453
2022-02-02 15:46:19 +01:00
FBTEST : bugs . core_4453
2022-01-23 20:41:55 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
import pytest
from firebird . qa import *
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
- - Tests that manipulates with NULL fields / domains and check results :
- - CORE - 1518 Adding a non - null restricted column to a populated table renders the table inconsistent
- - CORE - 4453 ( Regression : NOT NULL constraint , declared in domain , does not work )
- - CORE - 4725 ( Inconsistencies with ALTER DOMAIN and ALTER TABLE with DROP NOT NULL and PRIMARY KEYs )
- - CORE - 4733 ( Command " Alter table <T> alter TYPE <C> <DOMAIN_WITH_NOT_NULL " does not verifies data in column < C > and makes incorrect assignments in < C > to ZERO / JULIAN_DATE / ASCII ( 0 ) for types INT , TIMESTAMP and VARCHAR )
create domain dm_01 varchar ( 20 ) not null ;
commit ;
create table t_01 ( s dm_01 , x int ) ;
commit ;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory ( init = init_script )
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
insert into t_01 ( x ) values ( 100 ) ;
select * from t_01 where s is null ;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
act = isql_act ( ' db ' , test_script )
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stderr = """
2021-04-26 20:07:00 +02:00
Statement failed , SQLSTATE = 23000
validation error for column " T_01 " . " S " , value " *** null *** "
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version ( ' >=3.0 ' )
2022-01-23 20:41:55 +01:00
def test_1 ( act : Action ) :
act . expected_stderr = expected_stderr
act . execute ( )
assert act . clean_stderr == act . clean_expected_stderr
2021-04-26 20:07:00 +02:00