Skip to content

Commit 2007174

Browse files
authored
add Cols (#18)
1 parent 261d936 commit 2007174

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DataAPI"
22
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
33
authors = ["quinnj <[email protected]>"]
4-
version = "1.2.0"
4+
version = "1.3.0"
55

66
[compat]
77
julia = "1"

src/DataAPI.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,14 @@ struct All{T<:Tuple}
117117
All(args...) = new{typeof(args)}(args)
118118
end
119119

120+
"""
121+
Cols(cols...)
122+
123+
Select the union of the selections in `cols`. If `cols == ()`, select no columns.
124+
"""
125+
struct Cols{T<:Tuple}
126+
cols::T
127+
Cols(args...) = new{typeof(args)}(args)
128+
end
129+
120130
end # module

test/runtests.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,18 @@ end
7070

7171
end
7272

73-
@testset "All" begin
73+
@testset "All and Cols" begin
7474

75-
@test DataAPI.All().cols == ()
76-
@test DataAPI.All(1).cols == (1,)
77-
@test DataAPI.All([1,2,3], :a).cols == ([1, 2, 3], :a)
75+
for v in (DataAPI.All, DataAPI.Cols)
76+
@test v().cols == ()
77+
@test v(1).cols == (1,)
78+
@test v([1,2,3], :a).cols == ([1, 2, 3], :a)
7879

79-
a = DataAPI.All(DataAPI.All())
80-
@test length(a.cols) == 1
81-
@test a.cols[1] isa DataAPI.All
82-
@test a.cols[1].cols == ()
80+
a = v(v())
81+
@test length(a.cols) == 1
82+
@test a.cols[1] isa v
83+
@test a.cols[1].cols == ()
84+
end
8385

8486
end
8587

0 commit comments

Comments
 (0)