Skip to content

Commit

Permalink
Merge pull request #414 from zodb/issue411
Browse files Browse the repository at this point in the history
Fix an AttributeError if a persistent site manager is installed and i…
  • Loading branch information
jamadden authored Aug 27, 2020
2 parents 6eccc9f + a0dbe3a commit 60f4b8b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
variable ``RS_CACHE_POLL_TIMEOUT`` to a number of seconds before
importing RelStorage to use this.

- Avoid an ``AttributeError`` if a persistent ``zope.component`` site
manager is installed as the current site, it's a ghost, and we're
making a load query for the first time in a particular connection.
See :issue:`411`.

3.2.0 (2020-07-20)
==================

Expand Down
20 changes: 15 additions & 5 deletions src/relstorage/adapters/sql/dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,21 @@ def _quote_query_for_prepare(self, query):
def _find_datatypes_for_prepared_query(self):
# Deduce the datatypes based on the types of the columns
# we're sending as params.
result = ()
param_provider = ITypedParams(self.root, None)
if param_provider is not None:
result = param_provider.datatypes_for_parameters() # pylint:disable=assignment-from-no-return
return result
root = self.root
if ITypedParams.providedBy(root):
# Don't call the interface to adapt; that uses adapter
# hooks, which may be persistent objects and thus result
# in calling back into this method (if the query we're
# compiling for the first time is the load object query,
# and the site manager itself is a ghost).
#
# Since we don't actually expect to have any adapters,
# just an object (Insert or a subclass) that already
# provides the interface, all we need to do is check to
# see if it's provided; we don't need to query an adapter.
# See https://github.com/zodb/relstorage/issues/411
return root.datatypes_for_parameters()
return ()

def prepare(self):
# This is correct for PostgreSQL. This needs moved to a dialect specific
Expand Down

0 comments on commit 60f4b8b

Please sign in to comment.