6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00
firebird-qa/tests/bugs/core_1175_test.py

77 lines
1.9 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-19 17:54:56 +01:00
"""
ID: issue-1597
ISSUE: 1597
TITLE: Error "Data type unknown" when any UDF argument is a built-in function containing a DSQL parameter reference
DESCRIPTION:
For FB 3.x - this test uses UDF from ib_udf.
UDF usage is deprecated in FB 4+, see: ".../doc/README.incompatibilities.3to4.txt".
Functions div, frac, dow, sdow, getExactTimestampUTC and isLeapYear got safe replacement
in UDR library "udf_compat", see it in folder: ../plugins/udr/
JIRA: CORE-1175
FBTEST: bugs.core_1175
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
# version: 3.0
2021-04-26 20:07:00 +02:00
2021-12-31 12:06:51 +01:00
init_script_1 = """DECLARE EXTERNAL FUNCTION rtrim
CSTRING(255)
RETURNS CSTRING(255) FREE_IT
ENTRY_POINT 'IB_UDF_rtrim' MODULE_NAME 'ib_udf';
commit;
"""
2022-01-19 17:54:56 +01:00
db_1 = db_factory(init=init_script_1)
2021-12-31 12:06:51 +01:00
2022-01-19 17:54:56 +01:00
act_1 = python_act('db_1')
2021-12-31 12:06:51 +01:00
expected_stdout_1 = """Test PASSED!"""
2022-01-19 17:54:56 +01:00
@pytest.mark.version('>=3.0,<4.0')
2021-12-31 12:06:51 +01:00
def test_1(act_1: Action):
with act_1.db.connect() as con:
c = con.cursor()
try:
c.prepare('select * from RDB$DATABASE where RDB$CHARACTER_SET_NAME = rtrim(trim(?))')
except:
pytest.fail('Test FAILED')
# version: 4.0
init_script_2 = """
2021-04-26 20:07:00 +02:00
-- See declaration sample in plugins\\udr\\UdfBackwardCompatibility.sql:
create function UDR40_frac (
val double precision
) returns double precision
external name 'udf_compat!UC_frac'
engine udr;
create function UDR40_div (
n1 integer,
n2 integer
) returns double precision
external name 'udf_compat!UC_div'
engine udr;
commit;
2021-12-31 12:06:51 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-19 17:54:56 +01:00
db_2 = db_factory(init=init_script_2)
2021-04-26 20:07:00 +02:00
2022-01-19 17:54:56 +01:00
act_2 = python_act('db_2')
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=4.0')
2022-01-19 17:54:56 +01:00
def test_2(act_2: Action):
2021-12-31 12:06:51 +01:00
with act_2.db.connect() as con:
2021-11-10 19:02:05 +01:00
c = con.cursor()
try:
c.prepare('select 1 from rdb$database where UDR40_frac(?) != UDR40_div(?, ?) / ?')
except:
pytest.fail('Test FAILED')
2021-04-26 20:07:00 +02:00