Storm test suite fails when using psycopg2 2.2

Bug #585704 reported by James Henstridge
18
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Storm
Fix Released
Medium
James Henstridge

Bug Description

There are a number of failures in the Storm test suite when using psycopg2 2.2 as the database adapter.

The 2.2 release changed how psycopg2.Binary() objects are interpolated in queries to include an explicit cast. This shouldn't be a problem for cases where we want to include binary data, but it seems there are a few cases where we pass byte strings down that should be treated as text.

Below are the reported failures:

======================================================================
ERROR: test_case_default_like (tests.databases.postgres.PostgresTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/mocker.py", line 102, in test_method_wrapper
    result = test_method()
  File "tests/databases/postgres.py", line 272, in test_case_default_like
    result = self.connection.execute(expr)
  File "storm/databases/postgres.py", line 249, in execute
    return Connection.execute(self, statement, params, noresult)
  File "storm/database.py", line 237, in execute
    raw_cursor = self.raw_execute(statement, params)
  File "storm/databases/postgres.py", line 259, in raw_execute
    return Connection.raw_execute(self, statement, params)
  File "storm/database.py", line 321, in raw_execute
    self._check_disconnect(raw_cursor.execute, *args)
  File "storm/database.py", line 366, in _check_disconnect
    return function(*args, **kwargs)
ProgrammingError: operator does not exist: text ~~ bytea
LINE 1: ...FROM like_case_insensitive_test WHERE description LIKE E'%hu...
                                                             ^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

======================================================================
ERROR: test_case_insensitive_like (tests.databases.postgres.PostgresTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/mocker.py", line 102, in test_method_wrapper
    result = test_method()
  File "tests/databases/postgres.py", line 296, in test_case_insensitive_like
    result = self.connection.execute(expr)
  File "storm/databases/postgres.py", line 249, in execute
    return Connection.execute(self, statement, params, noresult)
  File "storm/database.py", line 237, in execute
    raw_cursor = self.raw_execute(statement, params)
  File "storm/databases/postgres.py", line 259, in raw_execute
    return Connection.raw_execute(self, statement, params)
  File "storm/database.py", line 321, in raw_execute
    self._check_disconnect(raw_cursor.execute, *args)
  File "storm/database.py", line 366, in _check_disconnect
    return function(*args, **kwargs)
ProgrammingError: operator does not exist: text ~~* bytea
LINE 1: ...FROM like_case_insensitive_test WHERE description ILIKE E'%h...
                                                             ^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

======================================================================
ERROR: test_case_sensitive_like (tests.databases.postgres.PostgresTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/mocker.py", line 102, in test_method_wrapper
    result = test_method()
  File "tests/databases/postgres.py", line 284, in test_case_sensitive_like
    result = self.connection.execute(expr)
  File "storm/databases/postgres.py", line 249, in execute
    return Connection.execute(self, statement, params, noresult)
  File "storm/database.py", line 237, in execute
    raw_cursor = self.raw_execute(statement, params)
  File "storm/databases/postgres.py", line 259, in raw_execute
    return Connection.raw_execute(self, statement, params)
  File "storm/database.py", line 321, in raw_execute
    self._check_disconnect(raw_cursor.execute, *args)
  File "storm/database.py", line 366, in _check_disconnect
    return function(*args, **kwargs)
ProgrammingError: operator does not exist: text ~~ bytea
LINE 1: ...FROM like_case_insensitive_test WHERE description LIKE E'%hu...
                                                             ^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

======================================================================
ERROR: test_get_insert_identity_composed (tests.databases.postgres.PostgresTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/mocker.py", line 102, in test_method_wrapper
    result = test_method()
  File "tests/databases/base.py", line 212, in test_get_insert_identity_composed
    result = self.connection.execute(select)
  File "storm/databases/postgres.py", line 249, in execute
    return Connection.execute(self, statement, params, noresult)
  File "storm/database.py", line 237, in execute
    raw_cursor = self.raw_execute(statement, params)
  File "storm/databases/postgres.py", line 259, in raw_execute
    return Connection.raw_execute(self, statement, params)
  File "storm/database.py", line 321, in raw_execute
    self._check_disconnect(raw_cursor.execute, *args)
  File "storm/database.py", line 366, in _check_disconnect
    return function(*args, **kwargs)
ProgrammingError: operator does not exist: character varying = bytea
LINE 1: ... = (SELECT currval('test_id_seq')) AND test.title = E'Title ...
                                                             ^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

======================================================================
ERROR: test_set_decimal_property (tests.store.postgres.PostgresStoreTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/mocker.py", line 102, in test_method_wrapper
    result = test_method()
  File "tests/store/base.py", line 5498, in test_set_decimal_property
    self.store.flush()
  File "storm/store.py", line 490, in flush
    self._flush_one(obj_info)
  File "storm/store.py", line 552, in _flush_one
    self._connection.execute(expr, noresult=True)
  File "storm/databases/postgres.py", line 249, in execute
    return Connection.execute(self, statement, params, noresult)
  File "storm/database.py", line 237, in execute
    raw_cursor = self.raw_execute(statement, params)
  File "storm/databases/postgres.py", line 259, in raw_execute
    return Connection.raw_execute(self, statement, params)
  File "storm/database.py", line 321, in raw_execute
    self._check_disconnect(raw_cursor.execute, *args)
  File "storm/database.py", line 366, in _check_disconnect
    return function(*args, **kwargs)
ProgrammingError: column "value" is of type numeric but expression is of type bytea
LINE 1: UPDATE money SET "value"=E'12.3456'::bytea WHERE money.id = ...
                         ^
HINT: You will need to rewrite or cast the expression.

----------------------------------------------------------------------
Ran 2432 tests in 145.240s

FAILED (errors=5)

Related branches

Changed in storm:
milestone: none → 0.17
Changed in storm:
assignee: nobody → James Henstridge (jamesh)
importance: Undecided → Medium
status: New → In Progress
Jamu Kakar (jkakar)
Changed in storm:
milestone: 0.17 → 0.18
Thomas Herve (therve)
Changed in storm:
status: In Progress → Fix Committed
Gary Poster (gary)
Changed in storm:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.