any way to detect this cycle?

Issue #2815 resolved
Mike Bayer repo owner created an issue

also why does it happen with append_whereclause, but not where?

from sqlalchemy import *
from sqlalchemy.sql import table, column

t = table('t', column('x'))

s = select([t](t))

s = s.append_whereclause(s.c.x > 5)

print s

Comments (4)

  1. Mike Bayer reporter

    eh? maybe

    diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py
    index e06262c..3ee0bfb 100644
    --- a/lib/sqlalchemy/sql/selectable.py
    +++ b/lib/sqlalchemy/sql/selectable.py
    @@ -1936,6 +1936,8 @@ class Select(HasPrefixes, SelectBase):
    
             def add(items):
                 for item in items:
    +                if item is self:
    +                    raise exc.InvalidRequestError("boom")
                     if translate and item in translate:
                         item = translate[item](item)
                     if not seen.intersection(item._cloned_set):
    
  2. Mike Bayer reporter

    that really only catches exactly this mistake and nothing else, but im not sure what other variants of this mistake there are.

  3. Log in to comment