Hi,

Before spamming the issue tracker and since I'm new to SQLAlchemy and may 
have misunderstood how to use `append_whereclause()`, I thought I seek 
confirmation on this mailing list.

The code:

    def test_append_whereclause(self):
        url = 'localhost'
        username = 'donald'
        password = 'duck'
        database_name = 'test_db'
        engine = create_engine('postgres://%s:%s@%s/%s' % (username, 
password, url, database_name))
        session = sessionmaker(bind=engine)()

        location = Table('location', metadata, 
            Column('id', Integer, Sequence('seq_location_id')),
            Column('name', String(256), nullable=False),
            Column('domestic', Boolean, default=False),
        )
        
        query = select(
            columns=[location.c.id.label('id')],
            from_obj=location,
            whereclause=location.c.id>50
        )
        query.append_whereclause(query.c.id < 100)
        result = session.execute(query)
        """ Causes exception:
            [...]
              File 
"/Library/Python/2.7/site-packages/sqlalchemy/sql/compiler.py", line 1214, 
in visit_select
                for f in froms])
              File 
"/Library/Python/2.7/site-packages/sqlalchemy/sql/visitors.py", line 74, in 
_compiler_dispatch
                return getter(visitor)(self, **kw)
              File 
"/Library/Python/2.7/site-packages/sqlalchemy/sql/compiler.py", line 1176, 
in visit_select
                for name, column in select._columns_plus_names
              File 
"/Library/Python/2.7/site-packages/sqlalchemy/sql/compiler.py", line 1070, 
in _label_select_column
                **column_clause_args
              File 
"/Library/Python/2.7/site-packages/sqlalchemy/sql/visitors.py", line 74, in 
_compiler_dispatch
                return getter(visitor)(self, **kw)
              File 
"/Library/Python/2.7/site-packages/sqlalchemy/sql/compiler.py", line 414, 
in visit_label
                OPERATORS[operators.as_] + \
              File 
"/Library/Python/2.7/site-packages/sqlalchemy/sql/visitors.py", line 74, in 
_compiler_dispatch
                return getter(visitor)(self, **kw)
              File 
"/Library/Python/2.7/site-packages/sqlalchemy/sql/compiler.py", line 429, 
in visit_column
                if not is_literal and isinstance(name, 
sql._truncated_label):
            RuntimeError: maximum recursion depth exceeded while calling a 
Python object        
        """        
        for r in result:
            print r

        session.commit()
        session.close()

The initial query generation happens without me knowing (or wanting to 
know) what and how it's generated. I'd like to be able to manipulate the 
query by adding where clauses. In order to access the columns, I use the 
initial query object. Is this how it's supposed to be used? It works fine 
if I convert the append_whereclause argument to a string, but left as the 
above, it's causing an exception.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to