6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_0389_test.py

106 lines
1.6 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-732
ISSUE: 732
TITLE: NULLS FIRST does not work with unions
DESCRIPTION:
JIRA: CORE-389
"""
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
init_script = """
2021-04-26 20:07:00 +02:00
create table t(x int);
insert into t values(2222);
insert into t values(222 );
insert into t values(22);
insert into t values(2);
insert into t values(null);
insert into t values(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
db = db_factory(page_size=4096, init=init_script)
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
select distinct x
from t
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
union all
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
select distinct x
from t
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
order by 1 nulls first
;
--------------------------
select distinct x
from t
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
union all
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
select distinct x
from t
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
order by 1 desc nulls first
;
--------------------------
select x
from t
union
select x
from t
order by 1 nulls first
;
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=[('=.*', '')])
expected_stdout = """
X
============
<null>
<null>
2
2
22
22
222
222
2222
2222
X
============
<null>
<null>
2222
2222
222
222
22
22
2
2
X
============
<null>
2
22
222
2021-04-26 20:07:00 +02:00
2222
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