@@ -2101,6 +2101,110 @@ def test_qb_is_type_as_function_arg_03(self):
21012101 )
21022102 self .assertEqual (sorted (result ), [6 , 13 , 20 ])
21032103
2104+ def test_qb_std_coalesce_01 (self ):
2105+ from models .orm_qb import default , std
2106+
2107+ query = std .coalesce (default .Inh_AB_AC , default .Inh_ABC ).select ('*' )
2108+ result = self .client .query (query )
2109+
2110+ self ._assertObjectsWithFields (
2111+ result ,
2112+ "a" ,
2113+ [
2114+ (
2115+ default .Inh_AB_AC ,
2116+ {
2117+ "a" : 17 ,
2118+ "b" : 18 ,
2119+ "c" : 19 ,
2120+ },
2121+ ),
2122+ ],
2123+ excluded_fields = {'ab' , 'ac' , 'bc' , 'abc' , 'ab_ac' },
2124+ )
2125+
2126+ def test_qb_std_coalesce_02 (self ):
2127+ from models .orm_qb import default , std
2128+
2129+ query = std .coalesce (default .Inh_AB .is_ (default .Inh_AC ), default .Inh_ABC ).select ('*' )
2130+ result = self .client .query (query )
2131+
2132+ self ._assertObjectsWithFields (
2133+ result ,
2134+ "a" ,
2135+ [
2136+ (
2137+ default .Inh_AB_AC ,
2138+ {
2139+ "a" : 17 ,
2140+ },
2141+ ),
2142+ ],
2143+ excluded_fields = {'b' , 'c' , 'ab' , 'ac' , 'bc' , 'abc' , 'ab_ac' },
2144+ )
2145+
2146+ def test_qb_std_union_01 (self ):
2147+ from models .orm_qb import default , std
2148+
2149+ query = std .union (default .Inh_ABC , default .Inh_AB_AC ).select ('*' )
2150+ result = self .client .query (query )
2151+
2152+ self ._assertObjectsWithFields (
2153+ result ,
2154+ "a" ,
2155+ [
2156+ (
2157+ default .Inh_ABC ,
2158+ {
2159+ "a" : 13 ,
2160+ "b" : 14 ,
2161+ "c" : 15 ,
2162+ },
2163+ ),
2164+ (
2165+ default .Inh_AB_AC ,
2166+ {
2167+ "a" : 17 ,
2168+ "b" : 18 ,
2169+ "c" : 19 ,
2170+ },
2171+ ),
2172+ ],
2173+ excluded_fields = {'ab' , 'ac' , 'bc' , 'abc' , 'ab_ac' },
2174+ )
2175+
2176+ def test_qb_std_union_02 (self ):
2177+ from models .orm_qb import default , std
2178+
2179+ query = std .union (
2180+ default .Inh_ABC , default .Inh_AB .is_ (default .Inh_AC )
2181+ ).select ('*' )
2182+ result = self .client .query (query )
2183+
2184+ self ._assertObjectsWithFields (
2185+ result ,
2186+ "a" ,
2187+ [
2188+ (
2189+ default .Inh_ABC ,
2190+ {
2191+ "a" : 13 ,
2192+ "b" : 14 ,
2193+ "c" : 15 ,
2194+ },
2195+ ),
2196+ (
2197+ default .Inh_AB_AC ,
2198+ {
2199+ "a" : 17 ,
2200+ "b" : 18 ,
2201+ "c" : 19 ,
2202+ },
2203+ ),
2204+ ],
2205+ excluded_fields = {'ab' , 'ac' , 'bc' , 'abc' , 'ab_ac' },
2206+ )
2207+
21042208
21052209class TestQueryBuilderModify (tb .ModelTestCase ):
21062210 """This test suite is for data manipulation using QB."""
0 commit comments