Closed Kamirus closed 4 years ago
Right now we allow querying from Table definitions like
Table
fooTable :: Table (c1 :: Int) fooTable = Table { name: "foo_table" }
Which when used to generate the SQL is used like
SELECT foo_table_0.c1 FROM foo_table foo_table_0
The name of the table foo_table is aliased using this name and a unique number
foo_table
We would like to write a query using PG function generate_series
SELECT tablealias.columnalias FROM generate_series(1,11) tablealias (columnalias);
Since datatype Table is used as a black box - meaning we only:
name
FROM
JOIN
(c1 :: Int)
Then we could provide a Table-like datatype with more general alias-generation
generateSeries :: Source ( col :: Int ) generateSeries = Source { source: \aliasSufix -> "generate_series(1,11) " <> "gs" <> aliasSufix <> " (col)" , alias: \aliasSufix -> "gs" <> aliasSufix }
source function would be used in FROM/JOIN clause alias function would be used in other places to refer to this source These depend on the aliasSufix supplied during SQL generation to ensure that aliases are unique
source
alias
aliasSufix
Currently
Right now we allow querying from
Table
definitions likeWhich when used to generate the SQL is used like
The name of the table
foo_table
is aliased using this name and a unique numberNew feature
We would like to write a query using PG function generate_series
Proposal
Since datatype
Table
is used as a black box - meaning we only:name
supplied in theTable
constructor afterFROM
(orJOIN
...)(c1 :: Int)
)Then we could provide a Table-like datatype with more general alias-generation
source
function would be used inFROM
/JOIN
clausealias
function would be used in other places to refer to this source These depend on thealiasSufix
supplied during SQL generation to ensure that aliases are unique