Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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-pylib
Commits
95e69cc4
Verified
Commit
95e69cc4
authored
4 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
ADD etag to query cache feature
parent
21a79809
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
F fsm
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosdb/common/models.py
+3
-0
3 additions, 0 deletions
src/caosdb/common/models.py
unittests/test_query.py
+5
-2
5 additions, 2 deletions
unittests/test_query.py
with
8 additions
and
2 deletions
src/caosdb/common/models.py
+
3
−
0
View file @
95e69cc4
...
@@ -3661,6 +3661,7 @@ class Query():
...
@@ -3661,6 +3661,7 @@ class Query():
self
.
flags
=
dict
()
self
.
flags
=
dict
()
self
.
messages
=
_Messages
()
self
.
messages
=
_Messages
()
self
.
cached
=
None
self
.
cached
=
None
self
.
etag
=
None
if
isinstance
(
q
,
etree
.
_Element
):
if
isinstance
(
q
,
etree
.
_Element
):
self
.
q
=
q
.
get
(
"
string
"
)
self
.
q
=
q
.
get
(
"
string
"
)
...
@@ -3670,6 +3671,7 @@ class Query():
...
@@ -3670,6 +3671,7 @@ class Query():
self
.
cached
=
False
self
.
cached
=
False
else
:
else
:
self
.
cached
=
q
.
get
(
"
cached
"
).
lower
()
==
"
true
"
self
.
cached
=
q
.
get
(
"
cached
"
).
lower
()
==
"
true
"
self
.
etag
=
q
.
get
(
"
etag
"
)
for
m
in
q
:
for
m
in
q
:
if
m
.
tag
.
lower
()
==
'
warning
'
or
m
.
tag
.
lower
()
==
'
error
'
:
if
m
.
tag
.
lower
()
==
'
warning
'
or
m
.
tag
.
lower
()
==
'
error
'
:
...
@@ -3714,6 +3716,7 @@ class Query():
...
@@ -3714,6 +3716,7 @@ class Query():
cresp
=
Container
.
_response_to_entities
(
http_response
)
cresp
=
Container
.
_response_to_entities
(
http_response
)
self
.
results
=
cresp
.
query
.
results
self
.
results
=
cresp
.
query
.
results
self
.
cached
=
cresp
.
query
.
cached
self
.
cached
=
cresp
.
query
.
cached
self
.
etag
=
cresp
.
query
.
etag
if
self
.
q
.
lower
().
startswith
(
'
count
'
)
and
len
(
cresp
)
==
0
:
if
self
.
q
.
lower
().
startswith
(
'
count
'
)
and
len
(
cresp
)
==
0
:
# this was a count query
# this was a count query
...
...
This diff is collapsed.
Click to expand it.
unittests/test_query.py
+
5
−
2
View file @
95e69cc4
...
@@ -26,20 +26,23 @@ import caosdb as db
...
@@ -26,20 +26,23 @@ import caosdb as db
def
test_query_parsing
():
def
test_query_parsing
():
s
=
'
<Query string=
"
FIND bla
"
results=
"
0
"
cached=
"
true
"
/>
'
s
=
'
<Query string=
"
FIND bla
"
results=
"
0
"
cached=
"
true
"
etag=
"
asdf
"
/>
'
q
=
db
.
Query
(
etree
.
fromstring
(
s
))
q
=
db
.
Query
(
etree
.
fromstring
(
s
))
assert
q
.
q
==
"
FIND bla
"
assert
q
.
q
==
"
FIND bla
"
assert
q
.
results
==
0
assert
q
.
results
==
0
assert
q
.
cached
is
True
assert
q
.
cached
is
True
assert
q
.
etag
==
"
asdf
"
s
=
'
<Query string=
"
COUNT bla
"
results=
"
1
"
cached=
"
false
"
/>
'
s
=
'
<Query string=
"
COUNT bla
"
results=
"
1
"
cached=
"
false
"
etag=
"
asdf
"
/>
'
q
=
db
.
Query
(
etree
.
fromstring
(
s
))
q
=
db
.
Query
(
etree
.
fromstring
(
s
))
assert
q
.
q
==
"
COUNT bla
"
assert
q
.
q
==
"
COUNT bla
"
assert
q
.
results
==
1
assert
q
.
results
==
1
assert
q
.
cached
is
False
assert
q
.
cached
is
False
assert
q
.
etag
==
"
asdf
"
s
=
'
<Query string=
"
COUNT blub
"
results=
"
4
"
/>
'
s
=
'
<Query string=
"
COUNT blub
"
results=
"
4
"
/>
'
q
=
db
.
Query
(
etree
.
fromstring
(
s
))
q
=
db
.
Query
(
etree
.
fromstring
(
s
))
assert
q
.
q
==
"
COUNT blub
"
assert
q
.
q
==
"
COUNT blub
"
assert
q
.
results
==
4
assert
q
.
results
==
4
assert
q
.
cached
is
False
assert
q
.
cached
is
False
assert
q
.
etag
is
None
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