2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
"""
|
|
|
|
ID: issue-991
|
|
|
|
ISSUE: 991
|
|
|
|
TITLE: Grouping on derived fields processing NULL data kills IB
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-629
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_0629
|
2022-01-18 20:45:21 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
set list on;
|
|
|
|
|
|
|
|
create or alter view v_test as select 1 id from rdb$database;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
recreate table test(
|
|
|
|
id integer not null,
|
|
|
|
dt_beg date,
|
|
|
|
dt_end date,
|
|
|
|
constraint pk_test primary key (id)
|
|
|
|
);
|
|
|
|
commit;
|
|
|
|
|
|
|
|
create or alter view v_test as
|
|
|
|
select id, extract(year from dt_beg) - extract(year from dt_end) dy
|
|
|
|
from test;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
insert into test values(1, '01.01.2015', null);
|
|
|
|
insert into test values(2, '01.01.2015', '01.01.2015');
|
|
|
|
insert into test values(3, null, null);
|
|
|
|
insert into test values(4, null, null);
|
|
|
|
insert into test values(5, '01.01.2015', '31.12.2014');
|
|
|
|
commit;
|
|
|
|
|
|
|
|
select dy from v_test group by dy;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
-------------------------------------------
|
|
|
|
|
|
|
|
create or alter view v_test as select 1 id from rdb$database;
|
|
|
|
commit;
|
|
|
|
recreate table test
|
|
|
|
(
|
|
|
|
a integer,
|
|
|
|
b date,
|
|
|
|
c computed by (extract(day from b)-extract(day from b))
|
|
|
|
);
|
|
|
|
commit;
|
|
|
|
insert into test(a, b) values(1, DATE '2015-05-24');
|
|
|
|
insert into test(a, b) values(1, null);
|
|
|
|
commit;
|
|
|
|
select c from test group by c;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
create or alter view v_test as select b-b as dd from test;
|
|
|
|
commit;
|
|
|
|
select dd from v_test group by dd;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
create or alter view v_test as select b-0 as dd from test;
|
|
|
|
select dd from v_test group by dd;
|
|
|
|
|
|
|
|
create or alter view v_test
|
|
|
|
as select cast(b as timestamp) as dt from test;
|
|
|
|
select dt from v_test group by dt;
|
|
|
|
|
|
|
|
------------
|
|
|
|
|
|
|
|
create or alter view v_test as select 1 id from rdb$database;
|
|
|
|
commit;
|
|
|
|
recreate table test(a int, b time, c computed by(cast(b as time)));
|
|
|
|
commit;
|
|
|
|
|
|
|
|
insert into test(a, b) values(1, '15:00:29.191');
|
|
|
|
insert into test(a, b) values(1, null);
|
|
|
|
commit;
|
|
|
|
|
|
|
|
select c from test group by c;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
act = isql_act('db', test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
DY <null>
|
|
|
|
DY 0
|
|
|
|
DY 1
|
2022-01-18 20:45:21 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
C <null>
|
|
|
|
C 0
|
2022-01-18 20:45:21 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
DD <null>
|
|
|
|
DD 0
|
2022-01-18 20:45:21 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
DD <null>
|
|
|
|
DD 2015-05-24
|
2022-01-18 20:45:21 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
DT <null>
|
|
|
|
DT 2015-05-24 00:00:00.0000
|
2022-01-18 20:45:21 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
C <null>
|
|
|
|
C 15:00:29.1910
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-18 20:45:21 +01:00
|
|
|
@pytest.mark.version('>=3')
|
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.execute()
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|
2021-04-26 20:07:00 +02:00
|
|
|
|