2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
"""
|
|
|
|
ID: issue-3437
|
|
|
|
ISSUE: 3437
|
|
|
|
TITLE: Allow the usage of blobs in COMPUTED BY expressions
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-3057
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_3057
|
2022-01-22 21:59:15 +01:00
|
|
|
"""
|
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
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
test_script = """
|
|
|
|
recreate table test(
|
|
|
|
b1 blob sub_type 1 character set utf8 collate unicode_ci_ai,
|
|
|
|
b2 blob sub_type 1 character set utf8 collate unicode_ci_ai,
|
2021-04-26 20:07:00 +02:00
|
|
|
bconcat1 computed by ( b1 || b2 ) -- this FAILS on 2.5.4
|
2022-01-22 21:59:15 +01:00
|
|
|
);
|
2021-04-26 20:07:00 +02:00
|
|
|
commit;
|
2022-01-22 21:59:15 +01:00
|
|
|
alter table test
|
2021-04-26 20:07:00 +02:00
|
|
|
add bconcat2 computed by ( b1 || b2 || bconcat1 )
|
|
|
|
,add brepl1_2 computed by ( replace(b1, b2, '1') )
|
|
|
|
,add brepl2_1 computed by ( replace(b2, b1, '2') )
|
|
|
|
;
|
|
|
|
commit;
|
|
|
|
--show table test;
|
|
|
|
insert into test(b1, b2) values(
|
|
|
|
'ÁÉÍÓÚÝÀÈÌÒÙÂÊÎÔÛÃÑÕÄËÏÖÜŸÇŠĄĘŹŻĂŞŢ',
|
|
|
|
'aeiouyaeiouaeiouanoaeiouycsaezzast'
|
|
|
|
);
|
2022-01-22 21:59:15 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
set list on;
|
|
|
|
set blob all;
|
2022-01-22 21:59:15 +01:00
|
|
|
select
|
|
|
|
b1 as blob_id_b1,
|
|
|
|
b2 as blob_id_b2,
|
|
|
|
bconcat1 as blob_id_bconcat1,
|
2021-04-26 20:07:00 +02:00
|
|
|
bconcat2 as blob_id_bconcat2,
|
|
|
|
brepl1_2 as blob_id_repl1_2,
|
|
|
|
brepl2_1 as blob_id_repl2_1
|
|
|
|
from test
|
|
|
|
;
|
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, substitutions=[('BLOB_ID_.*', 'BLOB_ID')])
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
BLOB_ID_B1 86:0
|
|
|
|
ÁÉÍÓÚÝÀÈÌÒÙÂÊÎÔÛÃÑÕÄËÏÖÜŸÇŠĄĘŹŻĂŞŢ
|
|
|
|
BLOB_ID_B2 86:1
|
|
|
|
aeiouyaeiouaeiouanoaeiouycsaezzast
|
|
|
|
BLOB_ID_BCONCAT1 0:12
|
|
|
|
ÁÉÍÓÚÝÀÈÌÒÙÂÊÎÔÛÃÑÕÄËÏÖÜŸÇŠĄĘŹŻĂŞŢaeiouyaeiouaeiouanoaeiouycsaezzast
|
|
|
|
BLOB_ID_BCONCAT2 0:f
|
|
|
|
ÁÉÍÓÚÝÀÈÌÒÙÂÊÎÔÛÃÑÕÄËÏÖÜŸÇŠĄĘŹŻĂŞŢaeiouyaeiouaeiouanoaeiouycsaezzastÁÉÍÓÚÝÀÈÌÒÙÂÊÎÔÛÃÑÕÄËÏÖÜŸÇŠĄĘŹŻĂŞŢaeiouyaeiouaeiouanoaeiouycsaezzast
|
|
|
|
BLOB_ID_REPL1_2 0:8
|
|
|
|
1
|
|
|
|
BLOB_ID_REPL2_1 0:5
|
|
|
|
2
|
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
|
|
|
|