Skip to content

Commit

Permalink
Assign column name to NULL that represents an empty column list
Browse files Browse the repository at this point in the history
  • Loading branch information
xitology committed Apr 23, 2023
1 parent 5eea5d5 commit a5aad0e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/src/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ Now we have all the components to construct the final query:
ORDER BY "condition_occurrence_1"."condition_occurrence_id"
) AS "condition_occurrence_2"
WHERE (EXISTS (
SELECT NULL
SELECT NULL AS "_"
FROM "visit_occurrence" AS "visit_occurrence_1"
JOIN "base_3" AS "base_4" ON ("visit_occurrence_1"."visit_concept_id" = "base_4"."concept_id")
WHERE
Expand Down
2 changes: 1 addition & 1 deletion docs/src/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ expression evaluated in the context of the outer query.
"visit_occurrence_1"."visit_source_concept_id"
FROM "visit_occurrence" AS "visit_occurrence_1"
WHERE (EXISTS (
SELECT NULL
SELECT NULL AS "_"
FROM "condition_occurrence" AS "condition_occurrence_1"
WHERE
("condition_occurrence_1"."person_id" = "visit_occurrence_1"."person_id") AND
Expand Down
20 changes: 10 additions & 10 deletions docs/src/test/nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ Query variables could be bound using the `Bind` constructor.
"person_1"."location_id"
FROM "person" AS "person_1"
WHERE (EXISTS (
SELECT NULL
SELECT NULL AS "_"
FROM "visit_occurrence" AS "visit_occurrence_1"
WHERE ("visit_occurrence_1"."person_id" = "person_1"."person_id")
))
Expand Down Expand Up @@ -606,7 +606,7 @@ subquery.
GROUP BY "visit_occurrence_1"."person_id"
) AS "visit_occurrence_2"
WHERE (EXISTS (
SELECT NULL
SELECT NULL AS "_"
FROM "observation" AS "observation_1"
WHERE
("observation_1"."person_id" = "visit_occurrence_2"."person_id") AND
Expand Down Expand Up @@ -743,7 +743,7 @@ A function invocation may include a nested query.
print(render(q))
#=>
SELECT (EXISTS (
SELECT NULL
SELECT NULL AS "_"
FROM "person" AS "person_1"
WHERE ("person_1"."year_of_birth" > 1950)
)) AS "exists"
Expand Down Expand Up @@ -1063,7 +1063,7 @@ An `Append` without any queries can be created explicitly.
#-> Append(args = [])

print(render(q))
#-> SELECT NULL
#-> SELECT NULL AS "_"

Without an explicit `Select`, the output of `Append` includes the common
columns of the nested queries.
Expand Down Expand Up @@ -1258,7 +1258,7 @@ An alias to an expression can be added with the `As` constructor.

print(render(q))
#=>
SELECT NULL
SELECT NULL AS "_"
FROM "person" AS "person_1"
=#

Expand Down Expand Up @@ -1349,7 +1349,7 @@ has no columns.

print(render(q))
#=>
SELECT NULL
SELECT NULL AS "_"
FROM "empty" AS "empty_1"
WHERE FALSE
=#
Expand Down Expand Up @@ -1520,7 +1520,7 @@ All the columns of a tabular function must have distinct names.

print(render(q))
#=>
SELECT NULL
SELECT NULL AS "_"
=#


Expand Down Expand Up @@ -1606,12 +1606,12 @@ We can create a temporary dataset using `With` and refer to it with `From`.
print(render(q))
#=>
WITH "male_1" ("_") AS (
SELECT NULL
SELECT NULL AS "_"
FROM "person" AS "person_1"
WHERE ("person_1"."gender_concept_id" = 8507)
),
"female_1" ("_") AS (
SELECT NULL
SELECT NULL AS "_"
FROM "person" AS "person_2"
WHERE ("person_2"."gender_concept_id" = 8532)
)
Expand Down Expand Up @@ -1867,7 +1867,7 @@ the group key expression.
Group()

print(render(q))
#-> SELECT NULL
#-> SELECT NULL AS "_"

A `SELECT DISTINCT` query must include all the keys even when they are not used
downstream.
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/bind.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ julia> print(render(q, tables = [person, visit_occurrence]))
SELECT "person_1"."person_id"
FROM "person" AS "person_1"
WHERE (EXISTS (
SELECT NULL
SELECT NULL AS "_"
FROM "visit_occurrence" AS "visit_occurrence_1"
WHERE ("visit_occurrence_1"."person_id" = "person_1"."person_id")
))
Expand Down
2 changes: 1 addition & 1 deletion src/translate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function complete(cols::OrderedDict{Symbol, SQLClause})
push!(args, col)
end
if isempty(args)
push!(args, LIT(missing))
push!(args, AS(over = LIT(missing), name = :_))
end
args
end
Expand Down

0 comments on commit a5aad0e

Please sign in to comment.