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_2974_test.py

65 lines
1.5 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-21 18:49:26 +01:00
"""
ID: issue-3356
ISSUE: 3356
TITLE: Unexpected "Invalid SIMILAR TO pattern" error
DESCRIPTION:
JIRA: CORE-2974
FBTEST: bugs.core_2974
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
db = db_factory()
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;
2022-01-21 18:49:26 +01:00
-- Should raise "Invalid SIMILAR TO pattern" error, as minus sign should be ecaped
2021-04-26 20:07:00 +02:00
select case when '-1' similar to '(-)%' then 1 else 0 end as chk_a
2022-01-21 18:49:26 +01:00
from rdb$database
2021-04-26 20:07:00 +02:00
;
-- Should raise "Invalid SIMILAR TO pattern" error because there is no "default" escape character:
select case when '-1' similar to '(\\-)%' then 1 else 0 end as chk_b
2022-01-21 18:49:26 +01:00
from rdb$database
2021-04-26 20:07:00 +02:00
;
-- Should NOT raise error:
select case when '-1' similar to '(\\-)%' escape '\\' then 1 else 0 end as chk_c
2022-01-21 18:49:26 +01:00
from rdb$database
2021-04-26 20:07:00 +02:00
;
2022-01-21 18:49:26 +01:00
-- works ok
2021-04-26 20:07:00 +02:00
-- Should NOT raise error:
select case when '-1' similar to '(\\+)%' then 1 else 0 end as chk_d
2022-01-21 18:49:26 +01:00
from rdb$database
2021-04-26 20:07:00 +02:00
;
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)
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
CHK_C 1
CHK_D 0
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 = 42000
Invalid SIMILAR TO pattern
Statement failed, SQLSTATE = 42000
Invalid SIMILAR TO pattern
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
@pytest.mark.version('>=3')
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