2021-04-26 20:07:00 +02:00
#coding:utf-8
#
# id: bugs.core_5062
# title: CHAR_TO_UUID on column with index throws expression evaluation not supported Human readable UUID argument for CHAR_TO_UUID must be of exact length 36
2021-11-26 19:20:43 +01:00
# decription:
2021-04-26 20:07:00 +02:00
# tracker_id: CORE-5062
# min_versions: ['2.5.6']
# versions: 2.5.6
# qmid: None
import pytest
2021-11-26 19:20:43 +01:00
from firebird . qa import db_factory , python_act , Action
2021-04-26 20:07:00 +02:00
# version: 2.5.6
# resources: None
substitutions_1 = [ ]
2021-11-26 19:20:43 +01:00
init_script_1 = """
recreate table test_uuid (
datavalue int ,
uuid char ( 16 ) character set octets ,
constraint test_uuid_unq unique ( uuid )
) ;
commit ;
insert into test_uuid ( datavalue , uuid ) values ( 1 , char_to_uuid ( ' 57F2B8C7-E1D8-4B61-9086-C66D1794F2D9 ' ) ) ;
- - insert into test_uuid ( datavalue , uuid ) values ( 2 , char_to_uuid ( ' 37F2B8C3-E1D8-4B31-9083-C33D1794F2D3 ' ) ) ;
commit ;
"""
2021-04-26 20:07:00 +02:00
db_1 = db_factory ( sql_dialect = 3 , init = init_script_1 )
# test_script_1
#---
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# # ::: NB ::: Could not reproduce ticket issue on x86.
# # Checked on: WI-V2.5.4.26856, WI-V3.0.0.31948 (Python = 2.7 x86, fdb = 1.5).
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# import fdb
# db_conn.close()
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# sql_ddl='''recreate table test_uuid(
2021-11-26 19:20:43 +01:00
# datavalue int,
# uuid char(16) character set octets,
2021-04-26 20:07:00 +02:00
# constraint test_uuid_unq unique(uuid)
# );
# commit;
# insert into test_uuid(datavalue, uuid) values( 1, char_to_uuid('57F2B8C7-E1D8-4B61-9086-C66D1794F2D9') );
# --insert into test_uuid(datavalue, uuid) values( 2, char_to_uuid('37F2B8C3-E1D8-4B31-9083-C33D1794F2D3') );
# commit;
# '''
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# runProgram('isql',['-user',user_name, '-pas',user_password, dsn],sql_ddl)
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# con2 = fdb.connect(dsn=dsn, user=user_name, password=user_password, charset='utf8')
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# xcur2 = con2.cursor()
2021-11-26 19:20:43 +01:00
# psSel = xcur2.stmt("select datavalue from test_uuid where uuid = char_to_uuid(?)")
#
2021-04-26 20:07:00 +02:00
# print ( psSel.plan )
# xcur2.execute(psSel, [('57F2B8C7-E1D8-4B61-9086-C66D1794F2D9')])
# for row in xcur2:
# print( row[0] )
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
# con2.close()
2021-11-26 19:20:43 +01:00
#
2021-04-26 20:07:00 +02:00
#---
2021-11-26 19:20:43 +01:00
act_1 = python_act ( ' db_1 ' , substitutions = substitutions_1 )
2021-04-26 20:07:00 +02:00
2021-11-26 19:20:43 +01:00
# Not needed for new implementation
#expected_stdout_1 = """
#PLAN (TEST_UUID INDEX (TEST_UUID_UNQ))
#1
#"""
2021-04-26 20:07:00 +02:00
2021-11-26 19:20:43 +01:00
@pytest.mark.version ( ' >=3.0 ' )
def test_1 ( act_1 : Action ) :
with act_1 . db . connect ( ) as con :
c = con . cursor ( )
stmt = c . prepare ( " select datavalue from test_uuid where uuid = char_to_uuid(?) " )
assert stmt . plan == ' PLAN (TEST_UUID INDEX (TEST_UUID_UNQ)) '
result = c . execute ( stmt , [ ' 57F2B8C7-E1D8-4B61-9086-C66D1794F2D9 ' ] ) . fetchall ( )
assert result == [ ( 1 , ) ]
2021-04-26 20:07:00 +02:00