Skip to content

Commit d23df8e

Browse files
committed
Added/Updated tests\bugs\core_4164_test.py: Checked on 6.0.0.835; 5.0.3.1661; 4.0.6.3207; 3.0.13.33807.
1 parent 131f9a2 commit d23df8e

File tree

1 file changed

+44
-38
lines changed

1 file changed

+44
-38
lines changed

tests/bugs/core_4164_test.py

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
DESCRIPTION:
88
JIRA: CORE-4164
99
FBTEST: bugs.core_4164
10+
NOTES:
11+
[17.07.2025] pzotov
12+
Checked on 6.0.0.835; 5.0.3.1661; 4.0.6.3207; 3.0.13.33807.
1013
"""
1114

1215
import pytest
@@ -25,49 +28,52 @@
2528
-- ==> and then do backup.
2629
"""
2730

28-
db = db_factory(from_backup='core4164.fbk', init=init_script)
31+
db = db_factory(from_backup='core4164.fbk')
2932

30-
test_script = """
31-
set width usr 10;
32-
set width grantor 10;
33-
set width priv 4;
34-
set width with_grant 6;
35-
set width obj_name 10;
36-
set width fld_name 15;
33+
act = isql_act('db', substitutions=[('=.*', '')])
3734

38-
select
39-
p.rdb$user usr
40-
,p.rdb$grantor grantor
41-
,p.rdb$privilege priv
42-
-- ::: NB ::: Field rdb$grant_option will contain NULLs after restoring,
43-
-- but <null> and 0 are considered by engine as the same in RDB$ tables.
44-
-- Decided to apply `coalesce` after consulting with Dmitry, letter 27.03.2015 19:26
45-
,coalesce(p.rdb$grant_option, 0) with_grant
46-
,p.rdb$relation_name obj_name
47-
,p.rdb$user_type usr_type
48-
,p.rdb$object_type obj_type
49-
,p.rdb$field_name fld_name
50-
from rdb$user_privileges p
51-
where upper(trim(p.rdb$relation_name)) in ( upper('g'), upper('e') )
52-
;
53-
"""
35+
@pytest.mark.version('>=3.0')
36+
def test_1(act: Action):
5437

55-
act = isql_act('db', test_script, substitutions=[('=.*', '')])
38+
SQL_SCHEMA_PREFIX = '' if act.is_version('<6') else 'PUBLIC.'
39+
test_script = f"""
40+
set width usr 10;
41+
set width grantor 10;
42+
set width priv 4;
43+
set width with_grant 6;
44+
set width obj_name 10;
45+
set width fld_name 15;
46+
set count on;
47+
select
48+
p.rdb$user usr
49+
,p.rdb$grantor grantor
50+
,p.rdb$privilege priv
51+
-- ::: NB ::: Field rdb$grant_option will contain NULLs after restoring,
52+
-- but <null> and 0 are considered by engine as the same in RDB$ tables.
53+
-- Decided to apply `coalesce` after consulting with Dmitry, letter 27.03.2015 19:26
54+
,coalesce(p.rdb$grant_option, 0) with_grant
55+
,p.rdb$relation_name obj_name
56+
,p.rdb$user_type usr_type
57+
,p.rdb$object_type obj_type
58+
,p.rdb$field_name fld_name
59+
from rdb$user_privileges p
60+
where upper(trim(p.rdb$relation_name)) in ( upper('g'), upper('e') )
61+
order by usr, grantor, obj_name, with_grant
62+
;
63+
"""
5664

57-
expected_stdout = """
58-
USR GRANTOR PRIV WITH_GRANT OBJ_NAME USR_TYPE OBJ_TYPE FLD_NAME
59-
========== ========== ==== ============ ========== ======== ======== ===============
60-
SYSDBA SYSDBA G 1 G 8 14 <null>
61-
SYSDBA SYSDBA G 1 E 8 7 <null>
62-
TMP$4164 SYSDBA G 0 G 8 14 <null>
63-
TMP$4164 SYSDBA G 0 E 8 7 <null>
64-
MGR$4164 SYSDBA G 1 G 8 14 <null>
65-
MGR$4164 SYSDBA G 1 E 8 7 <null>
66-
"""
65+
expected_stdout = """
66+
USR GRANTOR PRIV WITH_GRANT OBJ_NAME USR_TYPE OBJ_TYPE FLD_NAME
67+
MGR$4164 SYSDBA G 1 E 8 7 <null>
68+
MGR$4164 SYSDBA G 1 G 8 14 <null>
69+
SYSDBA SYSDBA G 1 E 8 7 <null>
70+
SYSDBA SYSDBA G 1 G 8 14 <null>
71+
TMP$4164 SYSDBA G 0 E 8 7 <null>
72+
TMP$4164 SYSDBA G 0 G 8 14 <null>
73+
Records affected: 6
74+
"""
6775

68-
@pytest.mark.version('>=3.0')
69-
def test_1(act: Action):
7076
act.expected_stdout = expected_stdout
71-
act.execute()
77+
act.isql(switches = ['-q'], input = test_script, combine_output = True)
7278
assert act.clean_stdout == act.clean_expected_stdout
7379

0 commit comments

Comments
 (0)