manila/manila/db/sqlalchemy
Goutham Pacha Ravi 7116f839e2 Fix with_entities usage in db queries
In order to retrieve shares with filters
pertaining to separate tables (shares, instances, metadata,
etc), we need to perform joined loads of those
respective database tables as necessary. After the
join, the query cannot select entities due to
Github issue #6253 - The following is an error when
the pattern is used:

sqlalchemy.exc.ArgumentError: Query has only expression-based entities - can't find property named "share_metadata".

sqlalchemy 1.4 has a performance improvement that
delays query processing [2] and disallows this
pattern of usage; we can use a query.count() instead.

In another instance, we can perform joins selectively
only if asked for.

[1] https://github.com/sqlalchemy/sqlalchemy/issues/625
[2] https://docs.sqlalchemy.org/en/14/changelog/migration_14.html#many-core-and-orm-statement-objects-now-perform-much-of-their-construction-and-validation-in-the-compile-phase

Change-Id: I8aa196c171bbc224cec06f517ea22c4e91cbc06a
Closes-Bug: #1926399
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
(cherry picked from commit 6ace54c260)
2021-05-21 19:11:40 +00:00
..
__init__.py Address H104 File contains nothing but comments 2014-07-14 10:19:15 +02:00
api.py Fix with_entities usage in db queries 2021-05-21 19:11:40 +00:00
models.py Remove unused model properties and increase unit test coverage 2021-03-23 09:27:48 -03:00
query.py Hacking: Fix E305 2020-04-01 11:43:29 +02:00
utils.py Support query user message by timestamp 2020-04-02 11:07:39 +08:00