MechanicalRabbit / FunSQL.jl

Julia library for compositional construction of SQL queries
https://mechanicalrabbit.github.io/FunSQL.jl
Other
144 stars 5 forks source link

No way to use rowid #61

Open jkroso opened 2 months ago

jkroso commented 2 months ago
render(conn, From(:anytable) |> Select(:rowid))

produces an error: ReferenceError: cannot find rowid

render(conn, From(:anytable) |> Select(“rowid"))

Almost works but it produces SELECT ‘rowid’ AS “_”

xitology commented 2 months ago

FunSQL currently has no way to refer to ROWID or other pseudo-columns (e.g. oid in PostgreSQL).

There are some workarounds. One is to include ROWID as an actual column of the table in the FunSQL catalog. However, it will make the pseudo-column always appear in the output, which may not be necessarily what the user wants. Perhaps, we need a way to declare a column hidden, so that it can be used in expressions, but would not appear in the output by default.

Alternatively, one could refer to ROWID using function/operator notation: Fun("ROWID "). Note the trailing space to suppress parentheses. However, if the query has a JOIN, or the FROM clause is wrapped in a subquery, the generated SQL will be invalid.