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

86 lines
2.5 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
#
# id: bugs.core_2420
# title: Parsing error in EXECUTE STATEMENT with named parameters
2021-11-16 19:44:53 +01:00
# decription:
2021-04-26 20:07:00 +02:00
# tracker_id: CORE-2420
# min_versions: []
# versions: 2.5
# qmid: None
import pytest
2021-11-16 19:44:53 +01:00
from firebird.qa import db_factory, python_act, Action
from firebird.driver import DatabaseError
2021-04-26 20:07:00 +02:00
# version: 2.5
# resources: None
substitutions_1 = []
init_script_1 = """recreate table sch (cod int, num int, name int, prevcod int, udl char(1), root int);
set term ^;
create or alter procedure getschdet(cod int, datedoc date, datedoc2 date,
p1 int, p2 int, p3 int, p4 int, p5 int, p6 int,
p7 int, p8 int, p9 int, p10 int, p11 int, p12 int, p13 int)
returns (summa int)
as
begin
suspend;
end ^
"""
db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
# test_script_1
#---
# c = db_conn.cursor()
# c.execute("""execute block as
# declare datedoc date;
# declare cod int;
# declare num int;
# declare name int;
# declare summa int;
# begin
# for execute statement (
# ' select s.cod,s.num, s.name,sum(g.summa) from sch s
# left join getschdet(s.cod,:datedoc ,:datedoc,0,0,0,0,0,0,0,0,0,0,0,1,3) g on 1=1
# where s.num in (''50'',''51'') and s.udl<>''У'' and s.root=1
# and not exists (select s2.cod from sch s2 where s2.prevcod=s.cod)
# group by 1,2,3') (datedoc := :datedoc)
# into :cod, :num, :name, :summa
# do exit;
# end""")
# print ('Execution OK')
2021-11-16 19:44:53 +01:00
#
2021-04-26 20:07:00 +02:00
#---
2021-11-16 19:44:53 +01:00
act_1 = python_act('db_1', substitutions=substitutions_1)
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=2.5')
2021-11-16 19:44:53 +01:00
def test_1(act_1: Action):
with act_1.db.connect() as con:
c = con.cursor()
# Test fails if next raises an exception
try:
c.execute("""execute block as
declare datedoc date;
declare cod int;
declare num int;
declare name int;
declare summa int;
begin
for execute statement (
' select s.cod,s.num, s.name,sum(g.summa) from sch s
left join getschdet(s.cod,:datedoc ,:datedoc,0,0,0,0,0,0,0,0,0,0,0,1,3) g on 1=1
where s.num in (''50'',''51'') and s.udl<>''У'' and s.root=1
and not exists (select s2.cod from sch s2 where s2.prevcod=s.cod)
group by 1,2,3') (datedoc := :datedoc)
into :cod, :num, :name, :summa
do exit;
end""")
except DatabaseError as exc:
pytest.fail(f"SQL execution failed with: {str(exc)}")
2021-04-26 20:07:00 +02:00