← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1298690] [NEW] sqlite regexp() function doesn't behave like mysql

 

Public bug reported:

In bug 1298494 I recently saw a case where the unit tests (using sqlite)
behaved differently than devstack with mysql.

The issue seems to be when we do

filters = {'uuid': group.members, 'deleted_at': None}
instances = instance_obj.InstanceList.get_by_filters(
                context, filters=filters)


Eventually down in db/sqlalchemy/api.py we end up calling

query = query.filter(column_attr.op(db_regexp_op)(
                                 str(filters[filter_name])))

where str(filters[filter_name]) is the string 'None'.

When using mysql, a regexp comparison of the string 'None' against a
NULL field fails to match.

Since sqlite doesn't have its own regexp function we provide one in
openstack/common/db/sqlalchemy/session.py.  In the buggy case we end up
calling it as regexp('None', None), where the types are "unicode" and
"NoneType".  However, we end up converting the second arg to text type
before calling reg.search() on it, so it matches.

This is a bug, we want the unit tests to behave like the real system.

** Affects: nova
     Importance: Undecided
         Status: New


** Tags: compute db

** Tags added: compute db

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1298690

Title:
  sqlite regexp() function doesn't behave like mysql

Status in OpenStack Compute (Nova):
  New

Bug description:
  In bug 1298494 I recently saw a case where the unit tests (using
  sqlite) behaved differently than devstack with mysql.

  The issue seems to be when we do

  filters = {'uuid': group.members, 'deleted_at': None}
  instances = instance_obj.InstanceList.get_by_filters(
                  context, filters=filters)

  
  Eventually down in db/sqlalchemy/api.py we end up calling

  query = query.filter(column_attr.op(db_regexp_op)(
                                   str(filters[filter_name])))

  where str(filters[filter_name]) is the string 'None'.

  When using mysql, a regexp comparison of the string 'None' against a
  NULL field fails to match.

  Since sqlite doesn't have its own regexp function we provide one in
  openstack/common/db/sqlalchemy/session.py.  In the buggy case we end
  up calling it as regexp('None', None), where the types are "unicode"
  and "NoneType".  However, we end up converting the second arg to text
  type before calling reg.search() on it, so it matches.

  This is a bug, we want the unit tests to behave like the real system.

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1298690/+subscriptions


Follow ups

References