Skip to content

Commit 94957d3

Browse files
committed
Merge branch 'release/0.20.0'
2 parents 8c882a3 + 604adc0 commit 94957d3

6 files changed

Lines changed: 276 additions & 56 deletions

File tree

.rtd-require

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
setuptools_scm
2-
suds-jurko
2+
suds-community
33
PyYAML
44
lxml

CHANGES.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,42 @@ Changelog
22
=========
33

44

5+
0.20.0 (2021-10-29)
6+
~~~~~~~~~~~~~~~~~~~
7+
8+
New features
9+
------------
10+
11+
+ `#86`_, `#89`_: allow SQL functions to be used on the attributes in
12+
the arguments to :meth:`icat.query.Query.setOrder` and
13+
:meth:`icat.query.Query.addConditions`.
14+
15+
Incompatible changes and new bugs
16+
---------------------------------
17+
18+
+ `#94`_: the implementation of `#89`_ changed the internal data
19+
structures in :attr:`icat.query.Query.conditions` and
20+
:attr:`icat.query.Query.order`. These attributes are considered
21+
internal and are deliberately not documented, so one could argue
22+
that this is not an incompatible change. But the changes also have
23+
an impact on the return value of :meth:`icat.query.Query.__repr__`
24+
such that it is not suitable to recreate the query object.
25+
26+
Bug fixes and minor changes
27+
---------------------------
28+
29+
+ `#90`_, `#91`_, `#95`_: :attr:`icat.query.Query.join_specs` was not
30+
taken into account in :meth:`icat.query.Query.copy` and
31+
:meth:`icat.query.Query.__repr__`.
32+
33+
.. _#86: https://github.com/icatproject/python-icat/issues/86
34+
.. _#89: https://github.com/icatproject/python-icat/pull/89
35+
.. _#90: https://github.com/icatproject/python-icat/issues/90
36+
.. _#91: https://github.com/icatproject/python-icat/issues/91
37+
.. _#94: https://github.com/icatproject/python-icat/issues/94
38+
.. _#95: https://github.com/icatproject/python-icat/pull/95
39+
40+
541
0.19.0 (2021-07-20)
642
~~~~~~~~~~~~~~~~~~~
743

README.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ Bugs and limitations
178178

179179
+ There are issues with ICAT server 4.8.0 and older when using
180180
suds-community, see `Issue #72`_ for details. Use suds-jurko when
181-
you need to talk to those older ICAT servers.
181+
you need to talk to those older ICAT servers. On the other hand,
182+
suds-jurko does can not be installed with setuptools 58.0.0 and
183+
newer.
182184

183185
+ If supported by the ICAT server (icat.server 4.9.0 and newer), the
184186
icat.config module queries the server for information on available
@@ -192,6 +194,11 @@ Bugs and limitations
192194
configuration variables and thus command line arguments are
193195
effective then those shown by the generic help message.
194196

197+
+ The return value of the formal string representation operator of
198+
class Query can not be used to recreate another query object with
199+
the same value as required by Python standards, see `Issue #94`_ for
200+
details.
201+
195202
+ For Python 2, the return value of the string representation operator
196203
of class Query may be a Unicode object if any of the conditions
197204
contains Unicode. This violates the specification that requires the
@@ -251,6 +258,7 @@ permissions and limitations under the License.
251258
.. _Read the Docs site: https://python-icat.readthedocs.io/
252259
.. _GitHub repository: https://github.com/icatproject/python-icat
253260
.. _Issue #72: https://github.com/icatproject/python-icat/issues/72
261+
.. _Issue #94: https://github.com/icatproject/python-icat/issues/94
254262
.. _PEP 440: https://www.python.org/dev/peps/pep-0440/
255263
.. _Semantic Versioning: https://semver.org/
256264
.. _Apache License: https://www.apache.org/licenses/LICENSE-2.0

doc/src/tutorial-search.rst

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,40 @@ We may also include related objects in the search results::
183183
visitId = "1.1-N"
184184
}]
185185

186+
python-icat supports the use of some JPQL functions when specifying
187+
which attribute a condition should be applied to. Consider the
188+
following query::
189+
190+
>>> query = Query(client, "Investigation", conditions={"LENGTH(title)": "= 18"})
191+
>>> print(query)
192+
SELECT o FROM Investigation o WHERE LENGTH(o.title) = 18
193+
>>> client.search(query)
194+
[(investigation){
195+
createId = "simple/root"
196+
createTime = 2021-10-05 14:09:57+00:00
197+
id = 430
198+
modId = "simple/root"
199+
modTime = 2021-10-05 14:09:57+00:00
200+
doi = "00.0815/inv-00601"
201+
endDate = 2010-10-12 15:00:00+00:00
202+
name = "10100601-ST"
203+
startDate = 2010-09-30 10:27:24+00:00
204+
title = "Ni-Mn-Ga flat cone"
205+
visitId = "1.1-N"
206+
}, (investigation){
207+
createId = "simple/root"
208+
createTime = 2021-10-05 14:09:58+00:00
209+
id = 431
210+
modId = "simple/root"
211+
modTime = 2021-10-05 14:09:58+00:00
212+
doi = "00.0815/inv-00409"
213+
endDate = 2012-08-06 01:10:08+00:00
214+
name = "12100409-ST"
215+
startDate = 2012-07-26 15:44:24+00:00
216+
title = "NiO SC OF1 JUH HHL"
217+
visitId = "1.1-P"
218+
}]
219+
186220
The conditions in a query may also be put on the attributes of related
187221
objects. This allows rather complex queries. Let us search for the
188222
datasets in this investigation that have been measured in a magnetic
@@ -668,6 +702,27 @@ dataset parameter, ordered by parameter type name (ascending), units
668702
}
669703
}]
670704

705+
In a similar way as for `conditions`, we may use JPQL functions also
706+
in the `order` argument to :class:`~icat.query.Query`. Let's search
707+
for user sorted by the length of their name, from longest to
708+
shortest::
709+
710+
>>> query = Query(client, "User", conditions={"fullName": "IS NOT NULL"}, order=[("LENGTH(fullName)", "DESC")])
711+
>>> print(query)
712+
SELECT o FROM User o WHERE o.fullName IS NOT NULL ORDER BY LENGTH(o.fullName) DESC
713+
>>> for user in client.search(query):
714+
... print("%d: %s" % (len(user.fullName), user.fullName))
715+
...
716+
19: Rudolph Beck-Dülmen
717+
19: Jean-Baptiste Botul
718+
16: Nicolas Bourbaki
719+
13: Aelius Cordus
720+
11: User Office
721+
10: Arnold Hau
722+
10: IDS reader
723+
8: John Doe
724+
4: Root
725+
671726
We may limit the number of returned items. Search for the second to
672727
last dataset to have been finished::
673728

0 commit comments

Comments
 (0)