Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype ADQL support #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/dialects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import .VARIABLE_STYLE.VariableStyle
module LIMIT_STYLE

@enum LimitStyle::UInt8 begin
ADQL
ANSI
MYSQL
POSTGRESQL
Expand All @@ -33,6 +34,8 @@ module LIMIT_STYLE
end

Base.convert(::Type{LimitStyle}, s::Symbol) =
s in (:adql, :ADQL) ?
ADQL :
s in (:ansi, :ANSI) ?
ANSI :
s in (:mysql, :MYSQL) ?
Expand All @@ -44,7 +47,7 @@ Base.convert(::Type{LimitStyle}, s::Symbol) =
s in (:sqlserver, :SQLSERVER) ?
SQLSERVER :
throw(DomainError(QuoteNode(s),
"expected :ansi, :mysql, :postgresql, :sqlite, or :sqlserver"))
"expected :adql, :ansi, :mysql, :postgresql, :sqlite, or :sqlserver"))

end

Expand Down
15 changes: 11 additions & 4 deletions src/serialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -632,14 +632,14 @@ function serialize!(c::LimitClause, ctx)
start = c.offset
count = c.limit
start !== nothing || count !== nothing || return
if ctx.dialect.limit_style === LIMIT_STYLE.MYSQL
if ctx.dialect.limit_style == LIMIT_STYLE.MYSQL
newline(ctx)
print(ctx, "LIMIT ")
if start !== nothing
print(ctx, start, ", ")
end
print(ctx, count !== nothing ? count : "18446744073709551615")
elseif ctx.dialect.limit_style == LIMIT_STYLE.POSTGRESQL
elseif ctx.dialect.limit_style in (LIMIT_STYLE.POSTGRESQL, LIMIT_STYLE.ADQL)
if count !== nothing
newline(ctx)
print(ctx, "LIMIT ", count)
Expand All @@ -648,7 +648,7 @@ function serialize!(c::LimitClause, ctx)
newline(ctx)
print(ctx, "OFFSET ", start)
end
elseif ctx.dialect.limit_style === LIMIT_STYLE.SQLITE
elseif ctx.dialect.limit_style == LIMIT_STYLE.SQLITE
newline(ctx)
print(ctx, "LIMIT ", count !== nothing ? count : -1)
if start !== nothing
Expand Down Expand Up @@ -806,12 +806,19 @@ function serialize!(c::SelectClause, ctx)
if top !== nothing
limit = top.limit
with_ties = top.with_ties
elseif ctx.dialect.limit_style === LIMIT_STYLE.SQLSERVER
elseif ctx.dialect.limit_style == LIMIT_STYLE.SQLSERVER
if @dissect(over, limit_over |> LIMIT(offset = nothing, limit = limit, with_ties = with_ties))
over = limit_over
elseif nested && @dissect(over, ORDER())
offset_0_rows = true
end
elseif ctx.dialect.limit_style == LIMIT_STYLE.ADQL
if @dissect(over, limit_over |> LIMIT(offset = offset, limit = limit, with_ties = with_ties))
over = limit_over
if offset !== nothing
over = LIMIT(over = over, offset = offset)
end
end
end
print(ctx, "SELECT")
if limit !== nothing
Expand Down
Loading