diff --git a/src/CaosDB.jl b/src/CaosDB.jl index e15b46db7c84354f7c72d818ce83fc57dee117b6..cbcd5675b023062042a439f6f718b84e421de187 100644 --- a/src/CaosDB.jl +++ b/src/CaosDB.jl @@ -29,7 +29,7 @@ export evaluate_return_code, CaosDBException, ClientException, GenericCaosDBException, CaosDBMessage # Exports from module Constants -export MIN_CCAOSDB_VERSION +export COLLECTION, DATATYPE, IMPORTANCE, MIN_CCAOSDB_VERSION, ROLE # Exports from module Utility export get_ccaosdb_version, get_env_fallback diff --git a/src/Constants.jl b/src/Constants.jl index 70b244eb3f7c545472325f2d49e608aea75fd241..4d3972e798839c09b7ad5ba4515e95a5fab0f491 100644 --- a/src/Constants.jl +++ b/src/Constants.jl @@ -23,7 +23,7 @@ module Constants -export MIN_CCAOSDB_VERSION +export COLLECTION, DATATYPE, IMPORTANCE, MIN_CCAOSDB_VERSION, ROLE """ The minimum version of CaosDB's cpplib and C interface that is @@ -31,4 +31,44 @@ supported by this version of CaosDB.jl. """ const MIN_CCAOSDB_VERSION = v"0.0.17" +# enums have to be encapsulated in modules to prevent namespce conflicts, see +# https://bleepcoder.com/julia/413856244/feature-request-getproperty-on-enum-type-to-access-instances +module DATATYPE +@enum _DATATYPE begin + UNSPECIFIED + BOOLEAN + INTEGER + DOUBLE + DATETIME + TEXT +end +end + +module COLLECTION +@enum _COLLECTION begin + SCALAR + LIST +end +end + +module ROLE +@enum _ROLE begin + UNSPECIFIED + RECORD + RECORD_TYPE + PROPERTY + FILE +end +end + +module IMPORTANCE +@enum _IMPORTANCE begin + UNSPECIFIED + OBLIGATORY + RECOMMENDED + SUGGESTED + FIX +end +end + end diff --git a/src/Entity.jl b/src/Entity.jl index ee18834d9d4a9273e53cddfd4eb8b2cb56cd9a4d..ae7fbb001d20b5912fd1e12d3c266946b0b376ae 100644 --- a/src/Entity.jl +++ b/src/Entity.jl @@ -200,7 +200,7 @@ Struct containing a pointer to the wrapped cpp DataType object. Meant for internal use only; use `CaosDB.Entity.create_<type>_datatype` to create a valid _DataType object or use the `set/get_datatype` functions. """ -mutable struct _DatatType +mutable struct _DataType wrapped_datatype::Ptr{Cvoid} _deletable::Bool @@ -214,7 +214,7 @@ mutable struct _DatatType ccall( (:caosdb_entity_delete_datatype, CaosDB.library_name), Cint, - (Ref{_DatatType},), + (Ref{_DataType},), Ref{_DataType}(t), ) end @@ -568,7 +568,7 @@ function create_list_of_reference_datatype(name::AbstractString) end function create_value( - value::Union{AbstractString,Number,Bool,Vactor{T}}, + value::Union{AbstractString,Number,Bool,Vector{T}}, ) where {T<:Union{AbstractString,Number,Bool}} in_type = typeof(value) @@ -643,8 +643,10 @@ function create_value( ) else # Should never enter here but treat it just in case - @throw ArgumentError( - "The argument of type $in_type couldn't be converted into a valid CaosDB value object.", + throw( + ArgumentError( + "The argument of type $in_type couldn't be converted into a valid CaosDB value object.", + ), ) end