6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 05:53:06 +01:00
firebird-qa/tests/functional/tabloid/test_join_on_position_function_result.py

69 lines
2.1 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-02-04 19:05:19 +01:00
"""
ID: tabloid.join-on-position-function-result
TITLE: Records with NULLs could be lost from resultset.
DESCRIPTION:
http://www.sql.ru/forum/actualutils.aspx?action=gotomsg&tid=1009792&msg=14032086
FBTEST: functional.tabloid.join_on_position_function_result
"""
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
recreate table t(id int, s varchar(30));
commit;
insert into t values(1, 'aaa');
insert into t values(11, 'bbb');
insert into t values(111, 'ccc');
insert into t values(12, 'ddd');
insert into t values(123, 'eee');
insert into t values(1234, 'fff');
commit;
set list on;
select t.id, t.s, x.p, position(','||cast(t.id as varchar(11))||',', x.p) k
from t
left join (select ',123,12,11,' p from rdb$database) x
on position(','||cast(t.id as varchar(11))||',', x.p)>0
;
"""
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
ID 1
S aaa
P <null>
K <null>
ID 11
S bbb
P ,123,12,11,
K 8
ID 111
S ccc
P <null>
K <null>
ID 12
S ddd
P ,123,12,11,
K 5
ID 123
S eee
P ,123,12,11,
K 1
ID 1234
S fff
P <null>
K <null>
"""
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
@pytest.mark.version('>=3.0')
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout