2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
#
|
|
|
|
# id: bugs.core_3829
|
|
|
|
# title: Bad alias table choice joining CTE
|
|
|
|
# decription:
|
|
|
|
# Confirmed wrong result on 2.5.1; no problem on 2.5.7 and above
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
# Checked on:
|
|
|
|
# 4.0.0.1635 SS: 1.848s.
|
|
|
|
# 3.0.5.33182 SS: 1.531s.
|
|
|
|
# 2.5.9.27146 SC: 0.572s.
|
|
|
|
#
|
|
|
|
# tracker_id: CORE-3829
|
|
|
|
# min_versions: ['2.5.7']
|
|
|
|
# versions: 2.5.7
|
|
|
|
# qmid: None
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
from firebird.qa import db_factory, isql_act, Action
|
|
|
|
|
|
|
|
# version: 2.5.7
|
|
|
|
# resources: None
|
|
|
|
|
|
|
|
substitutions_1 = [('[ \t]+', ' ')]
|
|
|
|
|
|
|
|
init_script_1 = """"""
|
|
|
|
|
|
|
|
db_1 = db_factory(from_backup='core3829.fbk', init=init_script_1)
|
|
|
|
|
|
|
|
test_script_1 = """
|
|
|
|
set list on;
|
|
|
|
with totalk (kk1, variant, tt, qq, mm, ff, f1, f2, f3, f4, f5) as
|
|
|
|
(
|
|
|
|
select ll.kk1, ll.variant,
|
|
|
|
sum (iif(ll.selector_y_n='Y', 1, 0)),
|
|
|
|
count(*), -- <<<< problem here
|
|
|
|
-- count(1), -- <<<< this doesn't work either
|
|
|
|
-- sum(1), -- <<<<< this neither
|
|
|
|
-- sum(iif(ll.variant=1,1,1)), -- <<<< workaround
|
|
|
|
sum (iif(ll.selector_m_f='M' and ll.selector_y_n='Y', 1, 0)),
|
|
|
|
sum (iif(ll.selector_m_f='F' and ll.selector_y_n='Y', 1, 0)),
|
|
|
|
sum(iif(ll.selector_1_5='1' and ll.selector_y_n='Y', 1, 0)),
|
|
|
|
sum(iif(ll.selector_1_5='2' and ll.selector_y_n='Y', 1, 0)),
|
|
|
|
sum(iif(ll.selector_1_5='3' and ll.selector_y_n='Y', 1, 0)),
|
|
|
|
sum(iif(ll.selector_1_5='4' and ll.selector_y_n='Y', 1, 0)),
|
|
|
|
sum(iif(ll.selector_1_5='5' and ll.selector_y_n='Y', 1, 0))
|
|
|
|
from testcte ll
|
|
|
|
group by 1, 2
|
|
|
|
)
|
|
|
|
select
|
|
|
|
ff.kk1,
|
|
|
|
ff.descrkk,
|
|
|
|
sum(t1.tt) "TT 1",
|
|
|
|
sum(t2.tt) "TT 2",
|
|
|
|
sum(t1.qq) "QQ 1",
|
|
|
|
sum(t2.qq) "QQ 2",
|
|
|
|
sum(t1.mm) "MM 1",
|
|
|
|
sum(t2.mm) "MM 2",
|
|
|
|
sum(t1.ff) "FF 1",
|
|
|
|
sum(t2.ff) "FF 2",
|
|
|
|
sum(t1.f1) "G1 1",
|
|
|
|
sum(t2.f1) "G1 2",
|
|
|
|
sum(t1.f2) "G2 1",
|
|
|
|
sum(t2.f2) "G2 2",
|
|
|
|
sum(t1.f3) "G3 1",
|
|
|
|
sum(t2.f3) "G3 2",
|
|
|
|
sum(t1.f4) "G4 1",
|
|
|
|
sum(t2.f4) "G4 2",
|
|
|
|
sum(t1.f5) "G5 1",
|
|
|
|
sum(t2.f5) "G5 2"
|
|
|
|
from testmain ff
|
|
|
|
left outer join totalk t1 on t1.kk1=ff.kk1 and t1.variant = 1
|
|
|
|
left outer join totalk t2 on t2.kk1=ff.kk1 and t2.variant = 2
|
|
|
|
group by 1, 2
|
|
|
|
;
|
|
|
|
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
|
|
|
|
|
|
|
|
expected_stdout_1 = """
|
|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
|
|
G1 2 <null>
|
|
|
|
G2 1 <null>
|
|
|
|
G2 2 <null>
|
|
|
|
G3 1 <null>
|
|
|
|
G3 2 <null>
|
|
|
|
G4 1 <null>
|
|
|
|
G4 2 <null>
|
|
|
|
G5 1 <null>
|
|
|
|
G5 2 <null>
|
|
|
|
|
|
|
|
KK1 B5
|
|
|
|
DESCRKK BBBBB
|
|
|
|
TT 1 <null>
|
|
|
|
TT 2 <null>
|
|
|
|
QQ 1 <null>
|
|
|
|
QQ 2 <null>
|
|
|
|
MM 1 <null>
|
|
|
|
MM 2 <null>
|
|
|
|
FF 1 <null>
|
|
|
|
FF 2 <null>
|
|
|
|
G1 1 <null>
|
|
|
|
G1 2 <null>
|
|
|
|
G2 1 <null>
|
|
|
|
G2 2 <null>
|
|
|
|
G3 1 <null>
|
|
|
|
G3 2 <null>
|
|
|
|
G4 1 <null>
|
|
|
|
G4 2 <null>
|
|
|
|
G5 1 <null>
|
|
|
|
G5 2 <null>
|
|
|
|
|
|
|
|
KK1 B6
|
|
|
|
DESCRKK BBBBBB
|
|
|
|
TT 1 <null>
|
|
|
|
TT 2 <null>
|
|
|
|
QQ 1 <null>
|
|
|
|
QQ 2 <null>
|
|
|
|
MM 1 <null>
|
|
|
|
MM 2 <null>
|
|
|
|
FF 1 <null>
|
|
|
|
FF 2 <null>
|
|
|
|
G1 1 <null>
|
|
|
|
G1 2 <null>
|
|
|
|
G2 1 <null>
|
|
|
|
G2 2 <null>
|
|
|
|
G3 1 <null>
|
|
|
|
G3 2 <null>
|
|
|
|
G4 1 <null>
|
|
|
|
G4 2 <null>
|
|
|
|
G5 1 <null>
|
|
|
|
G5 2 <null>
|
|
|
|
|
|
|
|
KK1 C1
|
|
|
|
DESCRKK C C C C C
|
|
|
|
TT 1 60
|
|
|
|
TT 2 65
|
|
|
|
QQ 1 117
|
|
|
|
QQ 2 121
|
|
|
|
MM 1 36
|
|
|
|
MM 2 32
|
|
|
|
FF 1 24
|
|
|
|
FF 2 33
|
|
|
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3 2 10
|
|
|
|
G4 1 12
|
|
|
|
G4 2 11
|
|
|
|
G5 1 14
|
|
|
|
G5 2 7
|
|
|
|
|
|
|
|
KK1 C5
|
|
|
|
DESCRKK CCCCC
|
|
|
|
TT 1 58
|
|
|
|
TT 2 51
|
|
|
|
QQ 1 113
|
|
|
|
QQ 2 112
|
|
|
|
MM 1 29
|
|
|
|
MM 2 17
|
|
|
|
FF 1 29
|
|
|
|
FF 2 34
|
|
|
|
G1 1 8
|
|
|
|
G1 2 15
|
|
|
|
G2 1 14
|
|
|
|
G2 2 8
|
|
|
|
G3 1 11
|
|
|
|
G3 2 11
|
|
|
|
G4 1 12
|
|
|
|
G4 2 6
|
|
|
|
G5 1 13
|
|
|
|
G5 2 11
|
|
|
|
|
|
|
|
KK1 C6
|
|
|
|
DESCRKK CCCCCC
|
|
|
|
TT 1 <null>
|
|
|
|
TT 2 <null>
|
|
|
|
QQ 1 <null>
|
|
|
|
QQ 2 <null>
|
|
|
|
MM 1 <null>
|
|
|
|
MM 2 <null>
|
|
|
|
FF 1 <null>
|
|
|
|
FF 2 <null>
|
|
|
|
G1 1 <null>
|
|
|
|
G1 2 <null>
|
|
|
|
G2 1 <null>
|
|
|
|
G2 2 <null>
|
|
|
|
G3 1 <null>
|
|
|
|
G3 2 <null>
|
|
|
|
G4 1 <null>
|
|
|
|
G4 2 <null>
|
|
|
|
G5 1 <null>
|
|
|
|
G5 2 <null>
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
@pytest.mark.version('>=2.5.7')
|
2021-04-28 12:42:11 +02:00
|
|
|
def test_1(act_1: Action):
|
2021-04-26 20:07:00 +02:00
|
|
|
act_1.expected_stdout = expected_stdout_1
|
|
|
|
act_1.execute()
|
2021-12-22 20:23:11 +01:00
|
|
|
assert act_1.clean_stdout == act_1.clean_expected_stdout
|
2021-04-26 20:07:00 +02:00
|
|
|
|