MechanicalRabbit / FunSQL.jl

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

`Define()` is ignored by `default_list()` #7

Closed xitology closed 3 years ago

xitology commented 3 years ago

Consider a query where Define overrides an existing column of a table:

using FunSQL: SQLTable, From, Define, Select, Get, render

person = SQLTable(:person, :person_id, :year_of_birth, :location_id)

q = From(person) |>
    Define(:year_of_birth => 0)

When the query does not have an explicit Select node, this Define node gets ignored:

print(render(q))
#=>
SELECT "person_1"."person_id", "person_1"."year_of_birth", "person_1"."location_id"
FROM "person" AS "person_1"
=#

One would expect that year_of_birth respects the redefinition. To fix this, we should make the columns created with Define to be included to the default output.

xitology commented 3 years ago

Fixed in 5db345e.