#coding:utf-8 # # id: bugs.core_2797 # title: Problem with default value of SP parameter # decription: # tracker_id: CORE-2797 # min_versions: ['2.5.0'] # versions: 3.0 # qmid: None import pytest from firebird.qa import db_factory, isql_act, Action # version: 3.0 # resources: None substitutions_1 = [('==.*', '')] init_script_1 = """""" db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1) test_script_1 = """ create or alter procedure sp_test as begin end; commit; set term ^; execute block as begin begin execute statement 'drop domain dm_dts_now'; when any do begin end end begin execute statement 'drop domain dm_dts_cts'; when any do begin end end begin execute statement 'drop domain dm_int_con'; when any do begin end end begin execute statement 'drop domain dm_vc_user'; when any do begin end end end ^ set term ;^ commit; create domain dm_dts_now timestamp default 'now' not null ; create domain dm_dts_cts timestamp default current_timestamp not null ; create domain dm_int_con int default current_connection; create domain dm_vc_user int default current_user; commit; set term ^; create or alter procedure sp_test ( in01 timestamp not null = 'now' ,in02 dm_dts_cts = current_timestamp ,in03 type of dm_dts_now = current_date ,in04 timestamp not null = 'now' ,in05 dm_dts_cts = current_timestamp ,in06 type of dm_dts_now = current_date ,in07 int not null = current_connection ,in08 dm_int_con = current_connection ,in09 dm_int_con = current_connection ,in10 varchar(31) = current_user ,in11 dm_vc_user = current_user ,in12 dm_vc_user = current_user ) as declare x integer; begin x = 0; end ^ set term ;^ commit; --set list on; set width ppar_name 15; set width ppar_fld_src 35; set width ppar_def_src 35; set width rdbf_fld_name 15; set width rdbf_def_src 35; select pp.rdb$parameter_name ppar_name ,replace(replace(cast( pp.rdb$field_source as varchar(35)), ascii_char(13), ''), ascii_char(10), '') ppar_fld_src ,replace(replace(cast( pp.rdb$default_source as varchar(35)), ascii_char(13), ''), ascii_char(10), '') ppar_def_src ,f.rdb$field_name rdbf_fld_name ,replace(replace(cast(f.rdb$default_source as varchar(35)), ascii_char(13), ''), ascii_char(10), '') rdbf_def_src from rdb$procedure_parameters pp left join rdb$fields f on pp.rdb$field_source = f.rdb$field_name where upper(trim(pp.rdb$procedure_name)) = upper('sp_test'); commit; """ act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1) expected_stdout_1 = """ PPAR_NAME PPAR_FLD_SRC PPAR_DEF_SRC RDBF_FLD_NAME RDBF_DEF_SRC IN01 RDB$1 = 'now' RDB$1 IN02 DM_DTS_CTS = current_timestamp DM_DTS_CTS default current_timestamp IN03 DM_DTS_NOW = current_date DM_DTS_NOW default 'now' IN04 RDB$2 = 'now' RDB$2 IN05 DM_DTS_CTS = current_timestamp DM_DTS_CTS default current_timestamp IN06 DM_DTS_NOW = current_date DM_DTS_NOW default 'now' IN07 RDB$3 = current_connection RDB$3 IN08 DM_INT_CON = current_connection DM_INT_CON default current_connection IN09 DM_INT_CON = current_connection DM_INT_CON default current_connection IN10 RDB$4 = current_user RDB$4 IN11 DM_VC_USER = current_user DM_VC_USER default current_user IN12 DM_VC_USER = current_user DM_VC_USER default current_user """ @pytest.mark.version('>=3.0') def test_1(act_1: Action): act_1.expected_stdout = expected_stdout_1 act_1.execute() assert act_1.clean_expected_stdout == act_1.clean_stdout