6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00
firebird-qa/tests/bugs/core_0623_test.py

117 lines
3.7 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-18 20:45:21 +01:00
"""
ID: issue-985
ISSUE: 985
TITLE: ORDER BY on a VIEW turns values in fields into NULL
DESCRIPTION:
NOTES:
[30.10.2019] NB: new datatype in FB 4.0 was introduces: numeric(38,0).
It can lead to additional ident of values when we show them in form "SET LIST ON",
so we have to ignore all internal spaces - see added 'substitution' section below.
JIRA: CORE-623
FBTEST: bugs.core_0623
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
create table p1 (
x_p1 numeric(10,0),
f_entrada date
);
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
create view vp1 (
x_p1,
f_entrada
) as
select x_p1, f_entrada from p1;
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
create table p2 (
x_p2 numeric(10,0),
p1_x_p1 numeric(10,0),
n_one numeric(10,0),
n_two numeric(10,0)
);
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
create view vp2 (
p1_x_p1,
n_one,
n_two
) as
select p1_x_p1, sum(n_one), sum(n_two)
from p2 group by p1_x_p1;
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
create view vvp1 (
p1_x_p1,
f_entrada,
n_one,
n_two
) as
select p1.x_p1, p1.f_entrada, p2.n_one, p2.n_two
from vp1 p1 left join vp2 p2 on p1.x_p1=p2.p1_x_p1;
commit;
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
insert into p1 values (1,'07/10/2001');
insert into p1 values (2,'07/13/2001');
insert into p1 values (3,'08/12/2001');
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
insert into p2 values (1,1,0,1);
insert into p2 values (2,2,1,0);
insert into p2 values (3,1,0,1);
commit;
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
select * from vvp1;
select * from vvp1 order by f_entrada;
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
insert into p1 values (4,'08/10/2001');
insert into p2 values (4,2,0,1);
insert into p2 values (5,2,1,1);
commit;
select * from vvp1;
select * from vvp1 order by f_entrada;
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, substitutions=[('=.*', ''), ('[ \t]+', ' ')])
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
P1_X_P1 F_ENTRADA N_ONE N_TWO
===================== =========== ===================== =====================
1 2001-07-10 0 2
2 2001-07-13 1 0
3 2001-08-12 <null> <null>
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
P1_X_P1 F_ENTRADA N_ONE N_TWO
===================== =========== ===================== =====================
1 2001-07-10 0 2
2 2001-07-13 1 0
3 2001-08-12 <null> <null>
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
P1_X_P1 F_ENTRADA N_ONE N_TWO
===================== =========== ===================== =====================
1 2001-07-10 0 2
2 2001-07-13 2 2
3 2001-08-12 <null> <null>
4 2001-08-10 <null> <null>
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
P1_X_P1 F_ENTRADA N_ONE N_TWO
===================== =========== ===================== =====================
1 2001-07-10 0 2
2 2001-07-13 2 2
4 2001-08-10 <null> <null>
3 2001-08-12 <null> <null>
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