MechanicalRabbit / FunSQL.jl

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

[FEATURE REQUEST] Pretty Printing of Rendered SQL #19

Closed TheCedarPrince closed 2 years ago

TheCedarPrince commented 2 years ago

Currently, the SQL that gets printed looks like this:

julia> println(sql)
SELECT "person_1"."person_id", "person_1"."gender_concept_id", "person_1"."year_of_birth",
 "person_1"."month_of_birth", "person_1"."day_of_birth", "person_1"."birth_datetime", "per
son_1"."race_concept_id", "person_1"."ethnicity_concept_id", "person_1"."location_id", "pe
rson_1"."provider_id", "person_1"."care_site_id", "person_1"."person_source_value", "perso
n_1"."gender_source_value", "person_1"."gender_source_concept_id", "person_1"."race_source
_value", "person_1"."race_source_concept_id", "person_1"."ethnicity_source_value", "person
_1"."ethnicity_source_concept_id"
FROM "person" AS "person_1"   

Which is fine if you are not later interfacing with the SQL. However, for printing to reports/tutorials/materials, the strings can come out looking very cluttered or hard to read. It would be nice if there could be a display dispatch or something that takes a SQLStatement and could print it out like this:

SELECT "person_1"."person_id",
       "person_1"."gender_concept_id",
       "person_1"."year_of_birth",
       "person_1"."month_of_birth",
       "person_1"."day_of_birth",
       "person_1"."birth_datetime",
       "person_1"."race_concept_id",
       "person_1"."ethnicity_concept_id",
       "person_1"."location_id",
       "person_1"."provider_id",
       "person_1"."care_site_id",
       "person_1"."person_source_value",
       "person_1"."gender_source_value",
       "person_1"."gender_source_concept_id",
       "person_1"."race_source_value",
       "person_1"."race_source_concept_id",
       "person_1"."ethnicity_source_value",
       "person_1"."ethnicity_source_concept_id"
FROM "person" AS "person_1"

Is this something that could be implemented? Thanks!

xitology commented 2 years ago

Implemented in #21

TheCedarPrince commented 2 years ago

Amazing! This is fantastic as I will be using this functionality to share my SQL statements with some collaborators very shortly. Thanks!