mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-23 22:13:05 +01:00
72 lines
1.9 KiB
Python
72 lines
1.9 KiB
Python
#coding:utf-8
|
|
#
|
|
# id: functional.arno.derived_tables.derived_tables_11
|
|
# title: Derived table 11 outer reference
|
|
# decription: Outer reference to upper scope-level is allowed. Such as fields inside derived table part of sub-query (IN-predicate).
|
|
# tracker_id:
|
|
# min_versions: []
|
|
# versions: 2.0
|
|
# qmid: functional.arno.derived_tables.derived_tables_11
|
|
|
|
import pytest
|
|
from firebird.qa import db_factory, isql_act, Action
|
|
|
|
# version: 2.0
|
|
# resources: None
|
|
|
|
substitutions_1 = []
|
|
|
|
init_script_1 = """CREATE TABLE Table_10 (
|
|
ID INTEGER NOT NULL,
|
|
DESCRIPTION VARCHAR(10)
|
|
);
|
|
|
|
COMMIT;
|
|
|
|
INSERT INTO Table_10 (ID, DESCRIPTION) VALUES (0, NULL);
|
|
INSERT INTO Table_10 (ID, DESCRIPTION) VALUES (1, 'one');
|
|
INSERT INTO Table_10 (ID, DESCRIPTION) VALUES (2, 'two');
|
|
INSERT INTO Table_10 (ID, DESCRIPTION) VALUES (3, 'three');
|
|
INSERT INTO Table_10 (ID, DESCRIPTION) VALUES (4, 'four');
|
|
INSERT INTO Table_10 (ID, DESCRIPTION) VALUES (5, 'five');
|
|
INSERT INTO Table_10 (ID, DESCRIPTION) VALUES (6, 'six');
|
|
INSERT INTO Table_10 (ID, DESCRIPTION) VALUES (7, 'seven');
|
|
INSERT INTO Table_10 (ID, DESCRIPTION) VALUES (8, 'eight');
|
|
INSERT INTO Table_10 (ID, DESCRIPTION) VALUES (9, 'nine');
|
|
|
|
COMMIT;
|
|
"""
|
|
|
|
db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
|
|
|
test_script_1 = """SELECT
|
|
t10.ID,
|
|
t10.Description
|
|
FROM
|
|
Table_10 t10
|
|
WHERE
|
|
t10.ID IN (SELECT dt.ID FROM (SELECT t1.ID FROM
|
|
Table_10 t1 WHERE t1.ID = t10.ID) dt);"""
|
|
|
|
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
|
|
|
|
expected_stdout_1 = """ ID DESCRIPTION
|
|
============ ===========
|
|
0 <null>
|
|
1 one
|
|
2 two
|
|
3 three
|
|
4 four
|
|
5 five
|
|
6 six
|
|
7 seven
|
|
8 eight
|
|
9 nine"""
|
|
|
|
@pytest.mark.version('>=2.0')
|
|
def test_derived_tables_11_1(act_1: Action):
|
|
act_1.expected_stdout = expected_stdout_1
|
|
act_1.execute()
|
|
assert act_1.clean_expected_stdout == act_1.clean_stdout
|
|
|