Skip to content

Commit de7eafb

Browse files
author
Pietro Vertechi
authored
support datavalue (#40)
* support datavalue * use SkipConstructor
1 parent 063e352 commit de7eafb

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/StructArrays.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ function __init__()
2020
isstringarray(::WeakRefStrings.StringArray) = true
2121
default_array(::Type{T}, d) where {T<:Union{AbstractString, Missing}} = WeakRefStrings.StringArray{T}(d)
2222
end
23+
Requires.@require DataValues="e7dc6d0d-1eca-5fa6-8ad6-5aecde8b7ea5" begin
24+
Base.@pure SkipConstructor(::Type{<:DataValues.DataValue}) = true
25+
end
2326
end
2427

2528
end # module

test/REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
Tables
22
PooledArrays
33
WeakRefStrings
4+
DataValues

test/runtests.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using StructArrays
22
using StructArrays: LazyRow
33
import Tables, PooledArrays, WeakRefStrings
4+
using DataValues: DataValue
45
using Test
56

67
# write your own tests here
@@ -408,3 +409,13 @@ end
408409
@test v.a == [i for i in 1:3, j in 1:4]
409410
@test v.b == [j for i in 1:3, j in 1:4]
410411
end
412+
413+
@testset "datavalues" begin
414+
a = DataValue(2)
415+
b = DataValue{Float64}()
416+
s = StructArray(i for i in (a, b))
417+
@test propertynames(s) == (:hasvalue, :value)
418+
@test s.hasvalue == [true, false]
419+
@test s.value isa Vector{Real}
420+
@test s.value[1] == 2
421+
end

0 commit comments

Comments
 (0)