Skip to content

Commit 0553a84

Browse files
committed
Test user defined functions too.
1 parent afc3f1f commit 0553a84

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/dbsetup/orm_qb.gel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,4 +618,8 @@ type Link_Inh_A {
618618
};
619619
};
620620

621+
function Read_Inh_A(x: Inh_A) -> int64 using (x.a ?? -1);
622+
function Read_Inh_A_Overload(x: Inh_A) -> int64 using (x.a ?? -1);
623+
function Read_Inh_A_Overload(x: Inh_AB) -> int64 using (x.ab ?? -1);
624+
621625
}

tests/test_qb.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,6 +2084,23 @@ def test_qb_is_type_as_function_arg_02(self):
20842084
excluded_fields={'ab', 'ac', 'bc', 'abc', 'ab_ac'},
20852085
)
20862086

2087+
def test_qb_is_type_as_function_arg_03(self):
2088+
# Test that exprs produced by is_ can be passed as function args to
2089+
# user defined function
2090+
from models.orm_qb import default
2091+
2092+
# Note, we do Inh_A[is Inh_B] since is_ currently pretends its return
2093+
# type is its argument type.
2094+
result = self.client.query(
2095+
default.Read_Inh_A(default.Inh_B.is_(default.Inh_A))
2096+
)
2097+
self.assertEqual(sorted(result), [4, 13, 17])
2098+
2099+
result = self.client.query(
2100+
default.Read_Inh_A_Overload(default.Inh_B.is_(default.Inh_A))
2101+
)
2102+
self.assertEqual(sorted(result), [6, 13, 20])
2103+
20872104

20882105
class TestQueryBuilderModify(tb.ModelTestCase):
20892106
"""This test suite is for data manipulation using QB."""

0 commit comments

Comments
 (0)