2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
"""
|
|
|
|
ID: issue-4098
|
|
|
|
ISSUE: 4098
|
|
|
|
TITLE: SIMILAR TO works wrongly
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-3754
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
init_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
recreate table test_a(id integer, cnt integer);
|
|
|
|
commit;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
db = db_factory(init=init_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
set heading off;
|
|
|
|
select iif( '1' similar to '(1|2){0,}', 1, 0)as result from rdb$database
|
|
|
|
union all
|
|
|
|
select iif( '1' similar to '(1|2){0,1}', 1, 0)from rdb$database
|
|
|
|
union all
|
|
|
|
select iif( '1' similar to '(1|2){1}', 1, 0)from rdb$database
|
|
|
|
union all
|
|
|
|
select iif( '123' similar to '(1|12[3]?){1}', 1, 0)from rdb$database
|
|
|
|
union all
|
|
|
|
select iif( '123' similar to '(1|12[3]?)+', 1, 0) from rdb$database
|
|
|
|
union all
|
|
|
|
select iif( 'qwertyqwertyqwe' similar to '(%qwe%){2,}', 1, 0) from rdb$database
|
|
|
|
union all
|
|
|
|
select iif( 'qwertyqwertyqwe' similar to '(%(qwe)%){2,}', 1, 0) from rdb$database
|
|
|
|
union all
|
|
|
|
select iif( 'qqqqqqqqqqqqqqq' similar to '(%q%){2,}', 1, 0) from rdb$database
|
|
|
|
;
|
|
|
|
-- BTW: result in WI-T3.0.0.31681 matches to Postgress 9.3, checked 24.02.2015
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
act = isql_act('db', test_script)
|
|
|
|
|
|
|
|
expected_stdout = """
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
@pytest.mark.version('>=3.0')
|
2022-01-22 21:59:15 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.execute()
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|
2021-04-26 20:07:00 +02:00
|
|
|
|