Skip to content

Commit edfbd6e

Browse files
committed
support Iterators.take(), same as first()
1 parent f497dfe commit edfbd6e

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/readfuncs.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ Base.unique(dbc::SQLCollection) = @modify(dbc.query) do q
2727
q |> Group(colnames(dbc)...) |> Select(colnames(dbc)...)
2828
end
2929

30-
Base.first(dbc::SQLCollection, n::Integer) = @modify(dbc.query) do q
30+
Base.first(dbc::SQLCollection, n::Integer) = Iterators.take(dbc, n)
31+
32+
Iterators.take(dbc::SQLCollection, n::Integer) = @modify(dbc.query) do q
3133
q |> Limit(n)
3234
end
3335

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ using TestItemRunner
8585
(@f sort(by=(@o _.i), rev=true)),
8686
(@f filter(@o _.j (0.1, 0.5, 0.6) || _.i > 8) sort(by=(@o _.i))),
8787
(@f sort(by=(@o (_.i, -_.j)), rev=true) first(__, 2)),
88-
(@f sort(by=(@o (_.i, -_.j)), rev=true) Iterators.drop(__, 5) first(__, 2)),
88+
(@f sort(by=(@o (_.i, -_.j)), rev=true) Iterators.drop(__, 5) Iterators.take(__, 2) first(__, 3)),
8989
]
9090
if f isa Tuple
9191
dbs, f = f

0 commit comments

Comments
 (0)