Skip to content

Commit fa049cf

Browse files
committed
Add LIMIT_STYLE.ADQL
1 parent 6de9a93 commit fa049cf

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/dialects.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import .VARIABLE_STYLE.VariableStyle
2525
module LIMIT_STYLE
2626

2727
@enum LimitStyle::UInt8 begin
28+
ADQL
2829
ANSI
2930
MYSQL
3031
POSTGRESQL
@@ -33,6 +34,8 @@ module LIMIT_STYLE
3334
end
3435

3536
Base.convert(::Type{LimitStyle}, s::Symbol) =
37+
s in (:adql, :ADQL) ?
38+
ADQL :
3639
s in (:ansi, :ANSI) ?
3740
ANSI :
3841
s in (:mysql, :MYSQL) ?
@@ -44,7 +47,7 @@ Base.convert(::Type{LimitStyle}, s::Symbol) =
4447
s in (:sqlserver, :SQLSERVER) ?
4548
SQLSERVER :
4649
throw(DomainError(QuoteNode(s),
47-
"expected :ansi, :mysql, :postgresql, :sqlite, or :sqlserver"))
50+
"expected :adql, :ansi, :mysql, :postgresql, :sqlite, or :sqlserver"))
4851

4952
end
5053

src/serialize.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,14 +632,14 @@ function serialize!(c::LimitClause, ctx)
632632
start = c.offset
633633
count = c.limit
634634
start !== nothing || count !== nothing || return
635-
if ctx.dialect.limit_style === LIMIT_STYLE.MYSQL
635+
if ctx.dialect.limit_style == LIMIT_STYLE.MYSQL
636636
newline(ctx)
637637
print(ctx, "LIMIT ")
638638
if start !== nothing
639639
print(ctx, start, ", ")
640640
end
641641
print(ctx, count !== nothing ? count : "18446744073709551615")
642-
elseif ctx.dialect.limit_style == LIMIT_STYLE.POSTGRESQL
642+
elseif ctx.dialect.limit_style in (LIMIT_STYLE.POSTGRESQL, LIMIT_STYLE.ADQL)
643643
if count !== nothing
644644
newline(ctx)
645645
print(ctx, "LIMIT ", count)
@@ -648,7 +648,7 @@ function serialize!(c::LimitClause, ctx)
648648
newline(ctx)
649649
print(ctx, "OFFSET ", start)
650650
end
651-
elseif ctx.dialect.limit_style === LIMIT_STYLE.SQLITE
651+
elseif ctx.dialect.limit_style == LIMIT_STYLE.SQLITE
652652
newline(ctx)
653653
print(ctx, "LIMIT ", count !== nothing ? count : -1)
654654
if start !== nothing
@@ -806,12 +806,19 @@ function serialize!(c::SelectClause, ctx)
806806
if top !== nothing
807807
limit = top.limit
808808
with_ties = top.with_ties
809-
elseif ctx.dialect.limit_style === LIMIT_STYLE.SQLSERVER
809+
elseif ctx.dialect.limit_style == LIMIT_STYLE.SQLSERVER
810810
if @dissect(over, limit_over |> LIMIT(offset = nothing, limit = limit, with_ties = with_ties))
811811
over = limit_over
812812
elseif nested && @dissect(over, ORDER())
813813
offset_0_rows = true
814814
end
815+
elseif ctx.dialect.limit_style == LIMIT_STYLE.ADQL
816+
if @dissect(over, limit_over |> LIMIT(offset = offset, limit = limit, with_ties = with_ties))
817+
over = limit_over
818+
if offset !== nothing
819+
over = LIMIT(over = over, offset = offset)
820+
end
821+
end
815822
end
816823
print(ctx, "SELECT")
817824
if limit !== nothing

0 commit comments

Comments
 (0)