@@ -3867,6 +3867,68 @@ ORDER BY film.film_id;
38673867` )
38683868}
38693869
3870+ func TestCustomSetReturningFunction (t * testing.T ) {
3871+ skipForCockroachDB (t ) // no set Set-Returning Functions
3872+
3873+ inventoryID := IntegerColumn ("inventoryID" )
3874+ filmsInStock := CTE ("film_in_stock" , inventoryID )
3875+
3876+ stmt := WITH (
3877+ filmsInStock .AS (
3878+ RawStatement ("SELECT * FROM dvds.film_in_stock(#filmID, #storeID)" ,
3879+ RawArgs {
3880+ "#filmID" : 1 ,
3881+ "#storeID" : 2 ,
3882+ }),
3883+ ),
3884+ )(
3885+ SELECT (
3886+ Inventory .AllColumns ,
3887+ ).FROM (Inventory .
3888+ INNER_JOIN (filmsInStock , Inventory .InventoryID .EQ (inventoryID )),
3889+ ),
3890+ )
3891+
3892+ testutils .AssertStatementSql (t , stmt , `
3893+ WITH film_in_stock ("inventoryID") AS (SELECT * FROM dvds.film_in_stock($1, $2)
3894+ )
3895+ SELECT inventory.inventory_id AS "inventory.inventory_id",
3896+ inventory.film_id AS "inventory.film_id",
3897+ inventory.store_id AS "inventory.store_id",
3898+ inventory.last_update AS "inventory.last_update"
3899+ FROM dvds.inventory
3900+ INNER JOIN film_in_stock ON (inventory.inventory_id = film_in_stock."inventoryID");
3901+ ` )
3902+
3903+ var dest []model.Inventory
3904+
3905+ err := stmt .Query (db , & dest )
3906+
3907+ require .NoError (t , err )
3908+ testutils .AssertJSON (t , dest , `
3909+ [
3910+ {
3911+ "InventoryID": 5,
3912+ "FilmID": 1,
3913+ "StoreID": 2,
3914+ "LastUpdate": "2006-02-15T10:09:17Z"
3915+ },
3916+ {
3917+ "InventoryID": 7,
3918+ "FilmID": 1,
3919+ "StoreID": 2,
3920+ "LastUpdate": "2006-02-15T10:09:17Z"
3921+ },
3922+ {
3923+ "InventoryID": 8,
3924+ "FilmID": 1,
3925+ "StoreID": 2,
3926+ "LastUpdate": "2006-02-15T10:09:17Z"
3927+ }
3928+ ]
3929+ ` )
3930+ }
3931+
38703932var customer0 = model.Customer {
38713933 CustomerID : 1 ,
38723934 StoreID : 1 ,
0 commit comments