manila/manila/db
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
..
migrations Fix inconsistent ordering caused by low datetime precision. 2021-03-15 13:27:25 -07:00
sqlalchemy Fix with_entities usage in db queries 2021-05-21 19:11:40 +00:00
__init__.py Remove vim headers 2014-10-06 15:00:27 +02:00
api.py Merge "Fix wrong totalcount returned by share listing query" 2021-03-25 21:36:36 +00:00
base.py Reuse 'periodic_task' from oslo_service 2015-07-20 19:38:19 +03:00
migration.py Remove vim headers 2014-10-06 15:00:27 +02:00