Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cpplib
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Commits
b6086b31
Verified
Commit
b6086b31
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Plain Diff
Merge branch 'f-query' into f-files
parents
7daa47c3
c84a193c
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!11
F files
Pipeline
#11584
failed
3 years ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/caosdb/transaction.h
+2
-13
2 additions, 13 deletions
include/caosdb/transaction.h
src/caosdb/transaction.cpp
+1
-3
1 addition, 3 deletions
src/caosdb/transaction.cpp
test/test_transaction.cpp
+12
-0
12 additions, 0 deletions
test/test_transaction.cpp
with
15 additions
and
16 deletions
include/caosdb/transaction.h
+
2
−
13
View file @
b6086b31
...
...
@@ -253,17 +253,6 @@ private:
std
::
unique_ptr
<
Entity
>
entity
;
};
// TODO(fspreck) One possibility for count-queries: Transaction gets a
// GetQueryCount function that returns exactly this. In case of a
// single FIND Query this will be equivalent to the Size of the
// ResultSet, but it may be different in case of Query + RetrieveById,
// and in case of COUNT queries which have an empty ResultSet. We have
// to think about how to extend this to transactions with more than
// one query in the future. My suggestion is to treat a transaction
// with more than one query as the union of the query results in which
// case the query count would return the cumulative number of
// results. This would even allow the combination of FIND, FIND
// unique, and COUNT, albeit a little strangely.
/**
* @brief Create a transaction via `CaosDBConnection.createTransaction()`
*/
...
...
@@ -391,7 +380,7 @@ public:
* this transaction. In all other cases, the return value will be
* -1.
*/
[[
nodiscard
]]
inline
auto
GetCountResult
()
const
->
int
{
[[
nodiscard
]]
inline
auto
GetCountResult
()
const
->
long
{
return
query_count
;
}
...
...
@@ -406,7 +395,7 @@ public:
}
/**
* Get a JSON representation of the respone.
* Get a JSON representation of the respon
s
e.
*
* For debugging.
*/
...
...
This diff is collapsed.
Click to expand it.
src/caosdb/transaction.cpp
+
1
−
3
View file @
b6086b31
...
...
@@ -169,8 +169,6 @@ Transaction::Transaction(
return
this
->
status
.
GetCode
();
}
// TODO(fspreck) What about count queries (mixed with retrievals),
// what about unique queries?
auto
Transaction
::
Query
(
const
std
::
string
&
query
)
noexcept
->
StatusCode
{
ASSERT_CAN_ADD_QUERY
...
...
@@ -190,7 +188,7 @@ auto Transaction::DeleteById(const std::string &id) noexcept -> StatusCode {
auto
*
sub_request
=
this
->
request
->
add_requests
();
sub_request
->
mutable_delete_request
()
->
set_id
(
id
);
this
->
status
=
TransactionStatus
::
READY
();
this
->
status
=
TransactionStatus
::
GO_ON
();
return
this
->
status
.
GetCode
();
}
...
...
This diff is collapsed.
Click to expand it.
test/test_transaction.cpp
+
12
−
0
View file @
b6086b31
...
...
@@ -177,4 +177,16 @@ TEST(test_transaction, test_update_entity) {
EXPECT_EQ
(
error
,
StatusCode
::
ORIGINAL_ENTITY_MISSING_ID
);
}
TEST
(
test_transaction
,
test_multi_deletion
)
{
const
auto
*
host
=
"localhost"
;
auto
configuration
=
InsecureConnectionConfiguration
(
host
,
8000
);
Connection
connection
(
configuration
);
auto
transaction
=
connection
.
CreateTransaction
();
EXPECT_EQ
(
transaction
.
GetStatus
().
GetCode
(),
StatusCode
::
INITIAL
);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
auto
status
=
transaction
->
DeleteById
(
"asdf"
);
EXPECT_EQ
(
status
,
StatusCode
::
GO_ON
);
}
}
}
// namespace caosdb::transaction
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