6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 14:03:06 +01:00
firebird-qa/tests/bugs/core_4848_test.py

76 lines
1.5 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-24 20:27:02 +01:00
"""
ID: issue-5144
ISSUE: 5144
TITLE: MERGE ... WHEN NOT MATCHED ... RETURNING returns wrong (non-null) values when no insert is performed
DESCRIPTION:
JIRA: CORE-4848
FBTEST: bugs.core_4848
2022-01-24 20:27:02 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on;
2022-01-24 20:27:02 +01:00
set count on;
2021-04-26 20:07:00 +02:00
recreate table t1 (n1 integer, n2 integer);
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
-- Case 1:
merge into t1
using (
select 1 x
from rdb$database
where 1 = 0
) on 1 = 1
when not matched then
insert values (1, 11)
returning n1, n2;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
-- Case 2:
merge into t1
using (
select 1 x
from rdb$database
where 1 = 1
) on 1 = 0
when not matched and 1 = 0 then
insert values (1, 11)
returning n1, n2;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
act = isql_act('db', test_script)
# version: 3.0
2021-04-26 20:07:00 +02:00
expected_stdout_1 = """
N1 <null>
N2 <null>
N1 <null>
N2 <null>
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0,<5.0')
2022-01-24 20:27:02 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout_1
act.execute()
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00
# version: 5.0
expected_stdout_2 = """
Records affected: 0
Records affected: 0
"""
@pytest.mark.version('>=5.0')
2022-01-24 20:27:02 +01:00
def test_2(act: Action):
act.expected_stdout = expected_stdout_2
act.execute()
assert act.clean_stdout == act.clean_expected_stdout