]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Make "shared" filter more compatible with diff DBs
authorzhhuabj <zhhuabj@cn.ibm.com>
Mon, 1 Apr 2013 05:30:00 +0000 (13:30 +0800)
committerzhhuabj <zhhuabj@cn.ibm.com>
Wed, 10 Apr 2013 10:10:23 +0000 (18:10 +0800)
commitde5c1e4f281f59d550b476919b27ac4e2aae14ac
treec58cfbdf3a471573998270d205ea1a0fe37b56cf
parent8ad5612317b906022c8d99efb5ed25dd9967866d
Make "shared" filter more compatible with diff DBs

For the type BOOLEAN, in sqlalchemy,
it's mapped to BOOLEAN type if the backend database supports it,
otherwise, it's mapped to one of the Integer types, like SMALLINT,
and restrict the values to 1(True) and 0(False).

query_filter = (... | model.shared))
The above filter will generate a SQL where clause like:
where ... OR xxx.shared

This is not supported in databases which don't support BOOLEAN type.
Change it as below to make it more compatible:
query_filter = (... | model.shared == True))

It will generate a SQL where clause as below:
where ... OR xxx.shared = ?

In Python, True == 1, so this change is compatible
with both databases supporting BOOLEAN and those not supporting it.

Fix bug 1161195

Change-Id: Ic0ce0816d63b576a3469de0ed92cae4b19a3690e
quantum/db/db_base_plugin_v2.py
quantum/tests/unit/midonet/test_midonet_plugin.py
quantum/tests/unit/test_db_plugin.py