On Wed, 2024-01-24 at 12:35 +0100, Gorka Eguileor wrote:
orm_field = getattr(model, field) # For values that must match and are iterables we use IN if (isinstance(value, collections.Iterable) and not isinstance(value, six.string_types)): # We cannot use in_ when one of the values is None if None not in value: return orm_field.in_(value)
return or_(orm_field == v for v in value)
Thanks for the tip. I ended adding another way to penetrate Cinder's layers and tinker with the query of sqlalchemy. The latter has a magical filter with "is_" that creates "WHERE Foo IS NULL" in the SQL statement. column_attr = getattr(models.Backup, key) query = query.filter(column_attr.is_(None)) See https://review.opendev.org/c/openstack/cinder/+/657543 Anyway, thanks again -- P