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

174 lines
3.8 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-21 18:49:26 +01:00
"""
ID: issue-3199
ISSUE: 3199
TITLE: Prohibit any improper mixture of explicit and implicit joins
DESCRIPTION:
JIRA: CORE-2812
FBTEST: bugs.core_2812
2022-01-21 18:49:26 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
recreate table t_left(id int);
insert into t_left values(111);
insert into t_left values(999);
commit;
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
recreate table t_right(id int, val int);
insert into t_right values(111,0);
insert into t_right values(999,123456789);
commit;
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
recreate table t_middle(id int);
insert into t_middle values(1);
commit;
-- one more sample (after discussion with Dmitry by e-mail, 02-apr-2015 19:34)
2022-01-21 18:49:26 +01:00
recreate table t1(id int);
2021-04-26 20:07:00 +02:00
commit;
2022-01-21 18:49:26 +01:00
insert into t1 values( 1 );
2021-04-26 20:07:00 +02:00
commit;
recreate table test(x int);
insert into test values(1);
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
db = db_factory(init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on;
select
'case-1' as msg
,L.id proc_a_id
,m.id mid_id
,R.id b_id, R.val
from t_left L
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
, -- ::: nb ::: this is >>> COMMA <<< instead of `cross join`
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
t_middle m
left join t_right R on L.id=R.id
;
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
select
'case-2' as msg
,l.id a_id, m.id mid_id, r.id b_id, r.val
from t_left l
cross join t_middle m
left join t_right r on l.id=r.id;
-- Added 02-apr-2015:
2022-01-21 18:49:26 +01:00
select 'case-3' msg, a.id
2021-04-26 20:07:00 +02:00
from t1 a
2022-01-21 18:49:26 +01:00
, t1 b
join t1 c on a.id=c.id
2021-04-26 20:07:00 +02:00
where a.id=b.id; -- this FAILS on 3.0
2022-01-21 18:49:26 +01:00
select 'case-4' msg, a.id
2021-04-26 20:07:00 +02:00
from t1 b
2022-01-21 18:49:26 +01:00
, t1 a
join t1 c on a.id=c.id
2021-04-26 20:07:00 +02:00
where a.id=b.id; -- this WORKS on 3.0
---------------------------------------------------------
-- Added 29-jun-2017, after reading CORE-5573:
-- This should PASS:
select 1 as z1
2022-01-21 18:49:26 +01:00
from
2021-04-26 20:07:00 +02:00
test a
2022-01-21 18:49:26 +01:00
join
2021-04-26 20:07:00 +02:00
test s
2022-01-21 18:49:26 +01:00
inner join
2021-04-26 20:07:00 +02:00
(
2022-01-21 18:49:26 +01:00
test d
join test e on e.x = d.x
join ( test f join test g on f.x = g.x ) on e.x = g.x
2021-04-26 20:07:00 +02:00
--- and f.x=s.x
)
on 1=1
on g.x=d.x
;
-- This should FAIL on 3.0+ (but is passes on 2.5):
select 2 as z2
2022-01-21 18:49:26 +01:00
from
2021-04-26 20:07:00 +02:00
test a
2022-01-21 18:49:26 +01:00
join
2021-04-26 20:07:00 +02:00
test s
2022-01-21 18:49:26 +01:00
inner join
2021-04-26 20:07:00 +02:00
(
2022-01-21 18:49:26 +01:00
test d
join test e on e.x = d.x
join ( test f join test g on f.x = g.x ) on e.x = g.x
2021-04-26 20:07:00 +02:00
and f.x=s.x -- <<< !! <<<
)
on 1=1
on g.x=d.x
;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
act = isql_act('db', test_script, substitutions=[('=.*', ''), ('-At line.*', '')])
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
MSG case-2
A_ID 111
MID_ID 1
B_ID 111
VAL 0
MSG case-2
A_ID 999
MID_ID 1
B_ID 999
VAL 123456789
MSG case-4
ID 1
Z1 1
2021-12-22 20:23:11 +01:00
"""
2022-01-21 18:49:26 +01:00
expected_stderr = """
2021-04-26 20:07:00 +02:00
Statement failed, SQLSTATE = 42S22
Dynamic SQL Error
-SQL error code = -206
-Column unknown
-L.ID
Statement failed, SQLSTATE = 42S22
Dynamic SQL Error
-SQL error code = -206
-Column unknown
-A.ID
Statement failed, SQLSTATE = 42S22
Dynamic SQL Error
-SQL error code
-Column unknown
-S.X
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-21 18:49:26 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.expected_stderr = expected_stderr
act.execute()
assert (act.clean_stderr == act.clean_expected_stderr and
act.clean_stdout == act.clean_expected_stdout)
2021-04-26 20:07:00 +02:00