Comment 17 for bug 1926399

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to manila (master)

Reviewed: https://review.opendev.org/c/openstack/manila/+/792303
Committed: https://opendev.org/openstack/manila/commit/6ace54c2601770a0e06418ce5b98c756c86f6a51
Submitter: "Zuul (22348)"
Branch: master

commit 6ace54c2601770a0e06418ce5b98c756c86f6a51
Author: Goutham Pacha Ravi <email address hidden>
Date: Wed May 19 17:14:24 2021 -0700

    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 <email address hidden>