Skip to content
Snippets Groups Projects
Commit a68b3dbb authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

Merge branch 'f-release-results' into 'dev'

F release results

See merge request !12
parents cba6a1b9 c4dcd501
Branches
Tags v0.0.3
1 merge request!12F release results
Pipeline #14107 failed
...@@ -182,6 +182,7 @@ trigger_inttest: ...@@ -182,6 +182,7 @@ trigger_inttest:
-F "variables[TRIGGERED_BY_REF]=$TRIGGERED_BY_REF" -F "variables[TRIGGERED_BY_REF]=$TRIGGERED_BY_REF"
-F "variables[TRIGGERED_BY_HASH]=$TRIGGERED_BY_HASH" -F "variables[TRIGGERED_BY_HASH]=$TRIGGERED_BY_HASH"
-F "variables[JULIALIB_REGISTRY_IMAGE]=$JULIALIB_REGISTRY_IMAGE" -F "variables[JULIALIB_REGISTRY_IMAGE]=$JULIALIB_REGISTRY_IMAGE"
-F "variables[CPPLIB_REF]=${CPP_DEFAULT_BRANCH}"
-F "variables[F_BRANCH]=${F_BRANCH}" -F "variables[F_BRANCH]=${F_BRANCH}"
-F ref=${JULIAINT_REF} $JULIAINTTEST_PIPELINE 2>HTTPCODE -F ref=${JULIAINT_REF} $JULIAINTTEST_PIPELINE 2>HTTPCODE
......
...@@ -26,5 +26,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -26,5 +26,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
* `get_value` functions for properties and entities * `get_value` functions for properties and entities
* `retrieve` function (no SegFaults anymore)
### Security ### Security
...@@ -12,7 +12,7 @@ Order = [:module, :function, :macro, :type, :constant] ...@@ -12,7 +12,7 @@ Order = [:module, :function, :macro, :type, :constant]
## Public API ## Public API
```@autodocs ```@autodocs
Modules=[CaosDB, CaosDB.Exceptions, CaosDB.Info, CaosDB.Utility, Modules=[CaosDB, CaosDB.Exceptions, CaosDB.Constants, CaosDB.Info, CaosDB.Utility,
CaosDB.Connection, CaosDB.Authentication, CaosDB.Entity, CaosDB.Connection, CaosDB.Authentication, CaosDB.Entity,
CaosDB.Transaction] CaosDB.Transaction]
Private=false Private=false
...@@ -21,7 +21,7 @@ Private=false ...@@ -21,7 +21,7 @@ Private=false
## Expert-use only API functions ## Expert-use only API functions
```@autodocs ```@autodocs
Modules=[CaosDB, CaosDB.Exceptions, CaosDB.Info, CaosDB.Utility, Modules=[CaosDB, CaosDB.Exceptions, CaosDB.Constants, CaosDB.Info, CaosDB.Utility,
CaosDB.Connection, CaosDB.Authentication, CaosDB.Entity, CaosDB.Connection, CaosDB.Authentication, CaosDB.Entity,
CaosDB.Transaction] CaosDB.Transaction]
Public=false Public=false
......
...@@ -28,8 +28,11 @@ module CaosDB ...@@ -28,8 +28,11 @@ module CaosDB
export evaluate_return_code, export evaluate_return_code,
CaosDBException, ClientException, GenericCaosDBException, CaosDBMessage CaosDBException, ClientException, GenericCaosDBException, CaosDBMessage
# Exports from module Constants
export MIN_CCAOSDB_VERSION
# Exports from module Utility # Exports from module Utility
export get_env_fallback export get_ccaosdb_version, get_env_fallback
# Export from module Connection # Export from module Connection
export connect, connect_manually export connect, connect_manually
...@@ -122,6 +125,8 @@ end ...@@ -122,6 +125,8 @@ end
include("Exceptions.jl") include("Exceptions.jl")
include("Constants.jl")
include("Info.jl") include("Info.jl")
include("Utility.jl") include("Utility.jl")
...@@ -134,6 +139,7 @@ include("Entity.jl") ...@@ -134,6 +139,7 @@ include("Entity.jl")
include("Transaction.jl") include("Transaction.jl")
using .Exceptions, .Info, .Authentication, .Connection, .Utility, .Entity, .Transaction using .Exceptions,
.Constants, .Info, .Authentication, .Connection, .Utility, .Entity, .Transaction
end # CaosDB end # CaosDB
# ** header v3.0
# This file is a part of the CaosDB Project.
#
# Copyright (C) 2021 Indiscale GmbH <info@indiscale.com>
# Copyright (C) 2021 Florian Spreckelsen <f.spreckelsen@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License along with this program. If not, see
# <https://www.gnu.org/licenses/>.
#
# ** end header
#
module Constants
export MIN_CCAOSDB_VERSION
"""
The minimum version of CaosDB's cpplib and C interface that is
supported by this version of CaosDB.jl.
"""
const MIN_CCAOSDB_VERSION = v"0.0.16"
end
...@@ -433,6 +433,44 @@ function get_result_at(results::Ref{_ResultSet}, index::Cint) ...@@ -433,6 +433,44 @@ function get_result_at(results::Ref{_ResultSet}, index::Cint)
return entity return entity
end end
"""
function _release_result_at(results::Ref{_ResultSet}, index::Cint)
Return the entity at position `index` of the given `results`.
This function releases the entity from the result set and leaves the result set
in a corrupted state. It should only be used to release the entity from a
result set which is about to be destroyed anyway.
"""
function _release_result_at(results::Ref{_ResultSet}, index::Cint)
size = get_result_size(results)
if index > size
throw(
DomainError(
index,
"You tried to access the result at position $index but the result set only has $size results.",
),
)
end
entity = Ref{CaosDB.Entity._Entity}(CaosDB.Entity._Entity())
err_code = ccall(
(:caosdb_transaction_result_set_release_at, CaosDB.library_name),
Cint,
(Ref{_ResultSet}, Ref{CaosDB.Entity._Entity}, Cint),
results,
entity,
index - Cint(1),
)
CaosDB.Exceptions.evaluate_return_code(err_code)
return entity
end
""" """
function get_result_at(results::Ref{_ResultSet}, index::Integer) function get_result_at(results::Ref{_ResultSet}, index::Integer)
...@@ -448,7 +486,7 @@ end ...@@ -448,7 +486,7 @@ end
""" """
function get_results(result_set::Ref{_ResultSet}) function get_results(result_set::Ref{_ResultSet})
Return al results of the given `result_set`. Return all entities of the given `result_set`.
""" """
function get_results(result_set::Ref{_ResultSet}) function get_results(result_set::Ref{_ResultSet})
...@@ -469,6 +507,39 @@ function get_results(transaction::Ref{_Transaction}) ...@@ -469,6 +507,39 @@ function get_results(transaction::Ref{_Transaction})
return get_results(result_set) return get_results(result_set)
end end
"""
function _release_results(transaction::Ref{_Transaction})
Return all results fo the given `transaction`.
This function also leaves the transaction object in a corrupted state and
should only be used to release the results from a transaction which is about to
be destroyed anyway.
"""
function _release_results(transaction::Ref{_Transaction})
result_set = get_result_set(transaction)
return _release_results(result_set)
end
"""
function _release_results(result_set::Ref{_ResultSet})
Return all entities of the given `result_set`.
This function also leaves the result_set object in a corrupted state and
should only be used to release the entities from a result_set which is about to
be destroyed anyway.
"""
function _release_results(result_set::Ref{_ResultSet})
size = get_result_size(result_set)
return [_release_result_at(result_set, Cint(ii)) for ii = 1:size]
end
""" """
function execute_query( function execute_query(
query::AbstractString, query::AbstractString,
...@@ -495,7 +566,7 @@ function execute_query(query::AbstractString, name::AbstractString = "default") ...@@ -495,7 +566,7 @@ function execute_query(query::AbstractString, name::AbstractString = "default")
execute(transaction) execute(transaction)
return get_results(transaction) return _release_results(transaction)
end end
""" """
...@@ -526,7 +597,7 @@ function execute_query( ...@@ -526,7 +597,7 @@ function execute_query(
execute(transaction) execute(transaction)
return get_results(transaction) return _release_results(transaction)
end end
""" """
...@@ -544,7 +615,7 @@ function retrieve(id::AbstractString, name::AbstractString = "default") ...@@ -544,7 +615,7 @@ function retrieve(id::AbstractString, name::AbstractString = "default")
execute(transaction) execute(transaction)
return get_results(transaction)[1] return _release_results(transaction)[1]
end end
""" """
...@@ -561,7 +632,7 @@ function retrieve(id::AbstractString, connection::Ref{CaosDB.Connection._Connect ...@@ -561,7 +632,7 @@ function retrieve(id::AbstractString, connection::Ref{CaosDB.Connection._Connect
execute(transaction) execute(transaction)
return get_results(transaction)[1] return _release_results(transaction)[1]
end end
""" """
...@@ -585,7 +656,7 @@ function retrieve( ...@@ -585,7 +656,7 @@ function retrieve(
execute(transaction) execute(transaction)
return get_results(transaction) return _release_results(transaction)
end end
""" """
...@@ -608,7 +679,7 @@ function retrieve( ...@@ -608,7 +679,7 @@ function retrieve(
execute(transaction) execute(transaction)
return get_results(transaction) return _release_results(transaction)
end end
""" """
function insert_entity(entity::Ref{CaosDB.Entity._Entity}) function insert_entity(entity::Ref{CaosDB.Entity._Entity})
...@@ -620,7 +691,7 @@ function insert_entity(entity::Ref{CaosDB.Entity._Entity}) ...@@ -620,7 +691,7 @@ function insert_entity(entity::Ref{CaosDB.Entity._Entity})
transaction = create_transaction() transaction = create_transaction()
add_insert_entity(transaction, entity) add_insert_entity(transaction, entity)
execute(transaction) execute(transaction)
return get_results(transaction) return _release_results(transaction)
end end
""" """
function update_entity(entity::Ref{CaosDB.Entity._Entity}) function update_entity(entity::Ref{CaosDB.Entity._Entity})
...@@ -632,7 +703,7 @@ function update_entity(entity::Ref{CaosDB.Entity._Entity}) ...@@ -632,7 +703,7 @@ function update_entity(entity::Ref{CaosDB.Entity._Entity})
transaction = create_transaction() transaction = create_transaction()
add_update_entity(transaction, entity) add_update_entity(transaction, entity)
execute(transaction) execute(transaction)
return get_results(transaction) return _release_results(transaction)
end end
""" """
function delete_by_id(id::AbstractString) function delete_by_id(id::AbstractString)
...@@ -644,7 +715,7 @@ function delete_by_id(id::AbstractString) ...@@ -644,7 +715,7 @@ function delete_by_id(id::AbstractString)
transaction = create_transaction() transaction = create_transaction()
add_delete_by_id(transaction, id) add_delete_by_id(transaction, id)
execute(transaction) execute(transaction)
return get_results(transaction) return _release_results(transaction)
end end
""" """
function retrieve_and_download_file_by_id( function retrieve_and_download_file_by_id(
...@@ -659,7 +730,7 @@ function retrieve_and_download_file_by_id(id::AbstractString, download_path::Abs ...@@ -659,7 +730,7 @@ function retrieve_and_download_file_by_id(id::AbstractString, download_path::Abs
transaction = create_transaction() transaction = create_transaction()
add_retrieve_and_download_file_by_id(transaction, id, download_path) add_retrieve_and_download_file_by_id(transaction, id, download_path)
execute(transaction) execute(transaction)
return get_results(transaction) return _release_results(transaction)
end end
end # Transaction end # Transaction
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
# #
module Utility module Utility
export get_env_fallback export get_ccaosdb_version, get_env_fallback
using ..CaosDB using ..CaosDB
...@@ -47,4 +47,22 @@ function get_env_fallback(var::AbstractString, default::AbstractString = "") ...@@ -47,4 +47,22 @@ function get_env_fallback(var::AbstractString, default::AbstractString = "")
end end
"""
function get_ccaosdb_version()
Return the version of the CaosDB C interface that is used by
CaosDB.jl.
"""
function get_ccaosdb_version()
major =
ccall((:caosdb_constants_LIBCAOSDB_VERSION_MAJOR, CaosDB.library_name), Cint, ())
minor =
ccall((:caosdb_constants_LIBCAOSDB_VERSION_MINOR, CaosDB.library_name), Cint, ())
patch =
ccall((:caosdb_constants_LIBCAOSDB_VERSION_PATCH, CaosDB.library_name), Cint, ())
return VersionNumber("$major.$minor.$patch")
end
end # Utility end # Utility
...@@ -24,6 +24,11 @@ using Test ...@@ -24,6 +24,11 @@ using Test
using CaosDB using CaosDB
@testset "CaosDBUnitTests" begin @testset "CaosDBUnitTests" begin
@testset "TestCaosdbCppLibVersion" begin
@test CaosDB.Utility.get_ccaosdb_version() >= CaosDB.Constants.MIN_CCAOSDB_VERSION
end
@testset "TestUtility" begin @testset "TestUtility" begin
if haskey(ENV, "SHELL") if haskey(ENV, "SHELL")
shell_var = ENV["SHELL"] shell_var = ENV["SHELL"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment