2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-19 17:54:56 +01:00
|
|
|
"""
|
|
|
|
ID: issue-1577
|
|
|
|
ISSUE: 1577
|
|
|
|
TITLE: Prepare fails when having a parameter in a DSQL statement before a sub query
|
|
|
|
DESCRIPTION:
|
|
|
|
NOTES:
|
|
|
|
[19.1.2022]
|
|
|
|
Using WITH for prepare() call is important to dispose returned prepared statement before
|
|
|
|
connection is closed. Otherwise pytest will report unhandled exceptions in __del__ calls
|
|
|
|
as prepared statement objects are destructed at wrong time.
|
|
|
|
JIRA: CORE-1156
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_1156
|
2022-01-19 17:54:56 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-19 17:54:56 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-19 17:54:56 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-19 17:54:56 +01:00
|
|
|
act = python_act('db')
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-19 17:54:56 +01:00
|
|
|
@pytest.mark.version('>=3')
|
|
|
|
def test_1(act: Action):
|
|
|
|
with act.db.connect() as con:
|
2021-11-10 19:02:05 +01:00
|
|
|
c = con.cursor()
|
|
|
|
try:
|
2022-01-19 17:54:56 +01:00
|
|
|
with c.prepare('select count(*) from rdb$database where ? < (select count(*) from rdb$database)'):
|
|
|
|
pass
|
2021-11-10 19:02:05 +01:00
|
|
|
except:
|
|
|
|
pytest.fail('Test FAILED in case 1')
|
|
|
|
try:
|
2022-01-19 17:54:56 +01:00
|
|
|
with c.prepare('select count(*) from rdb$database where (select count(*) from rdb$database) > ?'):
|
|
|
|
pass
|
2021-11-10 19:02:05 +01:00
|
|
|
except:
|
|
|
|
pytest.fail('Test FAILED in case 2')
|
|
|
|
try:
|
2022-01-19 17:54:56 +01:00
|
|
|
with c.prepare('select count(*) from rdb$database where ? < cast ((select count(*) from rdb$database) as integer)'):
|
|
|
|
pass
|
2021-11-10 19:02:05 +01:00
|
|
|
except:
|
|
|
|
pytest.fail('Test FAILED in case 3')
|
|
|
|
try:
|
2022-01-19 17:54:56 +01:00
|
|
|
with c.prepare('select count(*) from rdb$database where 0 < (select count(*) from rdb$database)'):
|
|
|
|
pass
|
2021-11-10 19:02:05 +01:00
|
|
|
except:
|
|
|
|
pytest.fail('Test FAILED in case 4')
|
|
|
|
try:
|
2022-01-19 17:54:56 +01:00
|
|
|
with c.prepare('select count(*) from rdb$database where cast (? as integer) < (select count(*) from rdb$database)'):
|
|
|
|
pass
|
2021-11-10 19:02:05 +01:00
|
|
|
except:
|
|
|
|
pytest.fail('Test FAILED in case 5')
|