Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-julialib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-julialib
Commits
381fff84
Commit
381fff84
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Implement retrievals and update docstrings
parent
e40a8c77
No related branches found
Branches containing commit
No related tags found
1 merge request
!7
ENH: Implement queries and entity retrieval
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/src/api.md
+10
-2
10 additions, 2 deletions
docs/src/api.md
src/Transaction.jl
+81
-1
81 additions, 1 deletion
src/Transaction.jl
test/runtests.jl
+4
-3
4 additions, 3 deletions
test/runtests.jl
with
95 additions
and
6 deletions
docs/src/api.md
+
10
−
2
View file @
381fff84
...
...
@@ -5,16 +5,24 @@ interface. You also find the documentation of the internal API which
is meant for expert use only. Only use those if you know what you're
doing.
```
@index
Order = [:module, :function, :macro, :type, :constant]
```
## Public API
```
@autodocs
Modules=[CaosDB, CaosDB.Exceptions, CaosDB.Info, CaosDB.Utility, CaosDB.Connection, CaosDB.Authentication, CaosDB.Entity]
Modules=[CaosDB, CaosDB.Exceptions, CaosDB.Info, CaosDB.Utility,
CaosDB.Connection, CaosDB.Authentication, CaosDB.Entity,
CaosDB.Transaction]
Private=false
```
## Expert-use only API functions
```
@autodocs
Modules=[CaosDB, CaosDB.Exceptions, CaosDB.Info, CaosDB.Utility, CaosDB.Connection, CaosDB.Authentication, CaosDB.Entity]
Modules=[CaosDB, CaosDB.Exceptions, CaosDB.Info, CaosDB.Utility,
CaosDB.Connection, CaosDB.Authentication, CaosDB.Entity,
CaosDB.Transaction]
Public=false
```
This diff is collapsed.
Click to expand it.
src/Transaction.jl
+
81
−
1
View file @
381fff84
...
...
@@ -23,7 +23,7 @@
module
Transaction
export
create_transaction
export
create_transaction
,
add_retrieve_by_id
,
add_query
using
CaosDB
...
...
@@ -86,4 +86,84 @@ function create_transaction(connection::Ref{CaosDB.Connection._Connection})
return
transaction
end
"""
function add_retrieve_by_id(transaction::Ref{_Transaction}, id::AbstractString)
Add a sub-request to retrieve a single entity by its `id` to the given
`transaction`.
!!! info
This does not execute the transaction.
"""
function
add_retrieve_by_id
(
transaction
::
Ref
{
_Transaction
},
id
::
AbstractString
)
err_code
=
ccall
(
(
:
caosdb_transaction_transaction_retrieve_by_id
,
CaosDB
.
library_name
),
Cint
,
(
Ref
{
_Transaction
},
Cstring
),
transaction
,
id
,
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
end
"""
function add_retrieve_by_id(
transaction::Ref{_Transaction},
ids::Vector{T},
) where {T<:AbstractString}
Add a sub-request to retrieve several entities by their `ids` to the
given `transaction`.
!!! info
This does not execute the transaction.
"""
function
add_retrieve_by_id
(
transaction
::
Ref
{
_Transaction
},
ids
::
Vector
{
T
},
)
where
{
T
<:
AbstractString
}
err_code
=
ccall
(
(
:
caosdb_transaction_transaction_retrieve_by_ids
,
CaosDB
.
library_name
),
Cint
,
(
Ref
{
_Transaction
},
Ptr
{
Ptr
{
Cchar
}}),
transaction
,
ids
,
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
end
"""
function add_query(transaction::Ref{_Transaction}, query::AbstractString)
Add a query sub-request to the given `transaction`.
!!! warning
Only COUNT queris and FIND queries (and no SELECT queries) are
currently supported.
!!! info
This dows not execute the transaction
"""
function
add_query
(
transaction
::
Ref
{
_Transaction
},
query
::
AbstractString
)
err_code
=
ccall
(
(
:
caosdb_transaction_transaction_query
,
CaosDB
.
library_name
),
Cint
,
(
Ref
{
_Transaction
},
Cstring
),
transaction
,
query
,
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
err_code
)
end
end
# Transaction
This diff is collapsed.
Click to expand it.
test/runtests.jl
+
4
−
3
View file @
381fff84
...
...
@@ -71,15 +71,16 @@ using CaosDB
@test
CaosDB
.
Transaction
.
create_transaction
()
!=
nothing
@test
CaosDB
.
Transaction
.
create_transaction
(
"default"
)
!=
nothing
conn
=
CaosDB
.
Connection
.
get_connection
()
@test
CaosDB
.
Transaction
.
create_transaction
!=
nothing
@test
CaosDB
.
Transaction
.
create_transaction
(
conn
)
!=
nothing
# Retrieval works by a single id, by a list of ids, or by querying
trans1
=
CaosDB
.
Transaction
.
create_transaction
()
@test
CaosDB
.
Transaction
.
add_retrieve_by_id
(
trans1
,
"some_id"
)
==
nothing
trans2
=
CaosDB
.
Transaction
.
create_transaction
()
@test
CaosDB
.
Transaction
.
add_retrieve_by_id
([
"id1"
,
"id2"
,
"id3"
])
==
nothing
@test
CaosDB
.
Transaction
.
add_retrieve_by_id
(
trans2
,
[
"id1"
,
"id2"
,
"id3"
])
==
nothing
trans3
=
CaosDB
.
Transaction
.
create_transaction
()
@test
CaosDB
.
Transaction
.
add_query
(
"FIND ENTITY WITH id=123"
)
==
nothing
@test
CaosDB
.
Transaction
.
add_query
(
trans3
,
"FIND ENTITY WITH id=123"
)
==
nothing
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment