2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-25 22:55:48 +01:00
"""
ID : issue - 5668
ISSUE : 5668
TITLE : Invalid data type for negation ( minus operator )
DESCRIPTION :
JIRA : CORE - 5395
2022-02-02 15:46:19 +01:00
FBTEST : bugs . core_5395
2022-01-25 22:55:48 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
import pytest
from firebird . qa import *
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
db = db_factory ( )
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on ;
set term ^ ;
2022-01-25 22:55:48 +01:00
execute block returns ( eval_result int ) as
begin
for
execute statement ( ' select 1 from rdb$database where 1 = - :id ' ) ( id := - 1 )
into : eval_result
do
suspend ;
2021-04-26 20:07:00 +02:00
- - Statement failed , SQLSTATE = 42000
- - Dynamic SQL Error
- - - expression evaluation not supported
- - - Invalid data type for negation ( minus operator )
- - - At block line : 3 , col : 5
end
^
2022-01-25 22:55:48 +01:00
execute block returns ( eval_result int ) as
begin
for
execute statement ( ' select 1 from rdb$database where 1 = (:id) * -1 ' ) ( id := - 1 )
into : eval_result
do
suspend ;
2021-04-26 20:07:00 +02:00
- - Statement failed , SQLSTATE = 42000
- - Dynamic SQL Error
- - - expression evaluation not supported
- - - Invalid data type for multiplication in dialect N , N = 1 or 3
- - - At block line : 13 , col : 3
end
^
2022-01-25 22:55:48 +01:00
execute block returns ( eval_result int ) as
2021-04-26 20:07:00 +02:00
declare selected_year int ;
declare selected_mont int ;
2022-01-25 22:55:48 +01:00
begin
2021-04-26 20:07:00 +02:00
selected_year = extract ( year from current_timestamp ) ;
selected_mont = extract ( month from current_timestamp ) ;
2022-01-25 22:55:48 +01:00
for
2021-04-26 20:07:00 +02:00
execute statement ( ' select 1 from rdb$database where extract(year from current_timestamp)*100 + extract(month from current_timestamp) = ? * 100 + ? ' ) ( selected_year , selected_mont )
2022-01-25 22:55:48 +01:00
into : eval_result
do
suspend ;
2021-04-26 20:07:00 +02:00
- - Statement failed , SQLSTATE = 42000
- - Dynamic SQL Error
- - - expression evaluation not supported
- - - Invalid data type for multiplication in dialect N , N = 1 or 3
- - - At block line : 8 , col : 5
end
^
set term ; ^
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
act = isql_act ( ' db ' , test_script )
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
EVAL_RESULT 1
EVAL_RESULT 1
EVAL_RESULT 1
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version ( ' >=3.0.5 ' )
2022-01-25 22:55:48 +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