Skip to content
Snippets Groups Projects
Commit 0be053a7 authored by florian's avatar florian
Browse files

DRAFT: Add a lot of setters, getters, and helper functions

parent f5bd5529
No related branches found
No related tags found
1 merge request!7ENH: Implement queries and entity retrieval
Pipeline #11994 failed
...@@ -173,9 +173,11 @@ authenticator object from a configuration. ...@@ -173,9 +173,11 @@ authenticator object from a configuration.
""" """
mutable struct _Authenticator mutable struct _Authenticator
wrapped_authenticator::Ptr{Cvoid} wrapped_authenticator::Ptr{Cvoid}
_deletable::Bool
function _Authenticator(managed_by_julia::Bool = false) function _Authenticator(managed_by_julia::Bool = false)
auth = new() auth = new()
auth._deletable = false
if managed_by_julia if managed_by_julia
# Only append a finalizer for this if the object is # Only append a finalizer for this if the object is
# actually managed by Julia and not created and destroyed # actually managed by Julia and not created and destroyed
......
...@@ -34,9 +34,11 @@ to create an connection object from a configuration. ...@@ -34,9 +34,11 @@ to create an connection object from a configuration.
""" """
mutable struct _Connection mutable struct _Connection
wrapped_connection::Ptr{Cvoid} wrapped_connection::Ptr{Cvoid}
_deletable::Bool
function _Connection(managed_by_julia::Bool = false) function _Connection(managed_by_julia::Bool = false)
conn = new() conn = new()
conn._deletable = false
if managed_by_julia if managed_by_julia
# Only append a finalizer for this if the object is # Only append a finalizer for this if the object is
# actually managed by Julia and not created and destroyed # actually managed by Julia and not created and destroyed
...@@ -63,9 +65,11 @@ an certificate-provider object from a configuration. ...@@ -63,9 +65,11 @@ an certificate-provider object from a configuration.
""" """
mutable struct _CertificateProvider mutable struct _CertificateProvider
wrapped_certificate_provider::Ptr{Cvoid} wrapped_certificate_provider::Ptr{Cvoid}
_deletable::Bool
function _CertificateProvider(managed_by_julia::Bool = false) function _CertificateProvider(managed_by_julia::Bool = false)
prov = new() prov = new()
prov._deletable = false
if managed_by_julia if managed_by_julia
# Only append a finalizer for this if the object is # Only append a finalizer for this if the object is
# actually managed by Julia and not created and destroyed # actually managed by Julia and not created and destroyed
...@@ -92,9 +96,11 @@ an connection-configuration object from a configuration. ...@@ -92,9 +96,11 @@ an connection-configuration object from a configuration.
""" """
mutable struct _Configuration mutable struct _Configuration
wrapped_connection_configuration::Ptr{Cvoid} wrapped_connection_configuration::Ptr{Cvoid}
_deletable::Bool
function _Configuration(managed_by_julia::Bool = false) function _Configuration(managed_by_julia::Bool = false)
config = new() config = new()
config._deletable(false)
if managed_by_julia if managed_by_julia
# Only append a finalizer for this if the object is # Only append a finalizer for this if the object is
# actually managed by Julia and not created and destroyed # actually managed by Julia and not created and destroyed
......
This diff is collapsed.
...@@ -35,8 +35,10 @@ object. ...@@ -35,8 +35,10 @@ object.
""" """
mutable struct _Transaction mutable struct _Transaction
wrapped_transaction::Ptr{Cvoid} wrapped_transaction::Ptr{Cvoid}
_deletable::Bool
function _Transaction(managed_by_julia::Bool = false) function _Transaction(managed_by_julia::Bool = false)
trans = new() trans = new()
trans._deletable = false
if managed_by_julia if managed_by_julia
function f(t) function f(t)
ccall( ccall(
......
...@@ -68,7 +68,7 @@ using CaosDB ...@@ -68,7 +68,7 @@ using CaosDB
# return the correct code (Change it if this ever changes in # return the correct code (Change it if this ever changes in
# libcaosdb) # libcaosdb)
client_err = CaosDB.Exceptions.ClientException("Client error") client_err = CaosDB.Exceptions.ClientException("Client error")
@test client_err.msg == "Client_Err" @test client_err.msg == "Client error"
@test client_err.code == 9999 @test client_err.code == 9999
end end
...@@ -107,25 +107,28 @@ using CaosDB ...@@ -107,25 +107,28 @@ using CaosDB
rec_with_parent_and_props = CaosDB.Entity.create_record("TestRec") rec_with_parent_and_props = CaosDB.Entity.create_record("TestRec")
# cannot set an ID # cannot set an ID
@test_throws CaosDB.Exceptions.ClientException CaosDB.Entity.set_id("some_id") @test_throws CaosDB.Exceptions.ClientException CaosDB.Entity.set_id(
rec_with_parent_and_props,
"some_id",
)
par1 = CaosDB.Entity.create_parent(name = "Parent1") par1 = CaosDB.Entity.create_parent(name = "Parent1")
par2 = CaosDB.Entity.create_parent(name = "Parent2", id = "id_of_parent_2") par2 = CaosDB.Entity.create_parent(name = "Parent2", id = "id_of_parent_2")
CaosDB.Entity.append_parents(rec_with_parent_and_props, [par1, par2]) CaosDB.Entity.append_parents(rec_with_parent_and_props, [par1, par2])
@test length(CaosDB.Entity.get_parents(rec_with_parent_and_props)) == 2 @test length(CaosDB.Entity.get_parents(rec_with_parent_and_props)) == 2
@test CaosDB.Entity.get_name( @test CaosDB.Entity.get_name(
CaosDB.Entity.get_parent(rec_with_parent_and_props, 1), CaosDB.Entity.get_parent(rec_with_parent_and_props, Cint(1)),
) == "Parent1" ) == "Parent1"
@test CaosDB.Entity.get_name( @test CaosDB.Entity.get_name(
CaosDB.Entity.get_parent(rec_with_parent_and_props, 2), CaosDB.Entity.get_parent(rec_with_parent_and_props, Cint(2)),
) == "Parent2" ) == "Parent2"
@test CaosDB.Entity.get_id( @test CaosDB.Entity.get_id(
CaosDB.Entity.get_parent(rec_with_parent_and_props, 2), CaosDB.Entity.get_parent(rec_with_parent_and_props, Cint(2)),
) == "id_of_parent_2" ) == "id_of_parent_2"
CaosDB.Entity.remove_parent(rec_with_parent_and_props, 1) CaosDB.Entity.remove_parent(rec_with_parent_and_props, Cint(1))
@test length(CaosDB.Entity.get_parents(rec_with_parent_and_props)) == 1 @test length(CaosDB.Entity.get_parents(rec_with_parent_and_props)) == 1
@test CaosDB.Entity.get_name( @test CaosDB.Entity.get_name(
CaosDB.Entity.get_parent(rec_with_parent_and_props, 1), CaosDB.Entity.get_parent(rec_with_parent_and_props, Cint(1)),
) == "Parent2" ) == "Parent2"
prop1 = CaosDB.Entity.create_property(name = "Property1", value = "2") prop1 = CaosDB.Entity.create_property(name = "Property1", value = "2")
...@@ -144,7 +147,7 @@ using CaosDB ...@@ -144,7 +147,7 @@ using CaosDB
@test CaosDB.Entity.get_id( @test CaosDB.Entity.get_id(
CaosDB.Entity.get_properties(rec_with_parent_and_props)[2], CaosDB.Entity.get_properties(rec_with_parent_and_props)[2],
) == "id_of_property_2" ) == "id_of_property_2"
CaosDB.Entity.remove_property(rec_with_parent_and_props, 2) CaosDB.Entity.remove_property(rec_with_parent_and_props, Cint(2))
@test length(CaosDB.Entity.get_properties(rec_with_parent_and_props)) == 2 @test length(CaosDB.Entity.get_properties(rec_with_parent_and_props)) == 2
@test CaosDB.Entity.get_name( @test CaosDB.Entity.get_name(
CaosDB.Entity.get_properties(rec_with_parent_and_props)[2], CaosDB.Entity.get_properties(rec_with_parent_and_props)[2],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment