-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Package cleanup, improve test coverage, and fix tests
- Loading branch information
Showing
5 changed files
with
78 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
using .QueryOperators | ||
using .QueryOperators: Enumerable | ||
using .DataValues | ||
|
||
struct DataValueUnwrapRow{T} | ||
row::T | ||
end | ||
|
||
Base.getproperty(d::DataValueUnwrapRow, ::Type{T}, col::Int, nm::Symbol) where {T} = unwrap(getproperty(getfield(d, 1), T, col, nm)) | ||
Base.getproperty(d::DataValueUnwrapRow, nm::Symbol) = unwrap(getproperty(getfield(d, 1), nm)) | ||
Base.propertynames(d::DataValueUnwrapRow) = propertynames(getfield(d, 1)) | ||
Tables.istable(::Type{<:Enumerable}) = true | ||
Tables.rowaccess(::Type{<:Enumerable}) = true | ||
Tables.rows(e::Enumerable) = DataValueUnwrapper(e) | ||
|
||
struct DataValueUnwrapper{NT, S} | ||
struct DataValueUnwrapper{S} | ||
x::S | ||
end | ||
|
||
Tables.schema(dv::DataValueUnwrapper) = Tables.Schema(nondatavaluetype(eltype(dv.x))) | ||
Base.eltype(rows::DataValueUnwrapper) = DataValueUnwrapRow{eltype(rows.x)} | ||
Base.IteratorSize(::Type{DataValueUnwrapper{NT, S}}) where {NT, S} = Base.IteratorSize(S) | ||
Base.IteratorSize(::Type{DataValueUnwrapper{S}}) where {S} = Base.IteratorSize(S) | ||
Base.length(rows::DataValueUnwrapper) = length(rows.x) | ||
|
||
AccessStyle(::Type{E}) where {E <: QueryOperators.Enumerable} = RowAccess() | ||
schema(e::QueryOperators.Enumerable) = nondatavaluetype(eltype(e)) | ||
rows(e::E) where {E <: QueryOperators.Enumerable} = DataValueUnwrapper{schema(e), E}(e) | ||
|
||
function Base.iterate(rows::DataValueUnwrapper{NT}, st=()) where {NT <: NamedTuple{names}} where {names} | ||
function Base.iterate(rows::DataValueUnwrapper, st=()) | ||
x = iterate(rows.x, st...) | ||
x === nothing && return nothing | ||
row, st = x | ||
return DataValueUnwrapRow(row), (st,) | ||
end | ||
|
||
struct DataValueUnwrapRow{T} | ||
row::T | ||
end | ||
|
||
Base.getproperty(d::DataValueUnwrapRow, ::Type{T}, col::Int, nm::Symbol) where {T} = unwrap(getproperty(getfield(d, 1), T, col, nm)) | ||
Base.getproperty(d::DataValueUnwrapRow, nm::Symbol) = unwrap(getproperty(getfield(d, 1), nm)) | ||
Base.propertynames(d::DataValueUnwrapRow) = propertynames(getfield(d, 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters