add a test for window function queries
commitaa082a31aa5268ce8b1c8fc538dc4f2220cdf740
authorEitan Chatav <eitan.chatav@gmail.com>
dateSat 12 Jan 2019, 15:22 (8 years ago)
parent1724322
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+12
@@ -310,6 +310,18 @@ let
310310in printSQL query
311311:}
312312WITH "cte1" AS (SELECT * FROM "tab" AS "tab"), "cte2" AS (SELECT * FROM "cte1" AS "cte1") SELECT * FROM "cte2" AS "cte2"
313+
314+window function queries
315+
316+>>> :{
317+let
318+ query :: Query '[] (Public Schema) '[] ["col1" ::: 'NotNull 'PGint4, "rank" ::: 'NotNull 'PGint8]
319+ query = select
320+ (List #col1 & Also ((rank `as` #rank) `Over` (partitionBy (#col1 :* Nil) & orderBy [#col2 & Asc])))
321+ (from (table #tab))
322+in printSQL query
323+:}
324+SELECT "col1" AS "col1", rank() OVER (PARTITION BY "col1" ORDER BY "col2" ASC) AS "rank" FROM "tab" AS "tab"
313325-}
314326newtype Query
315327 (commons :: FromType)