ah right, the statement caching code has been updated recently when I
transitioned from dogpile, it just needs this:
diff --git a/examples/dogpile_caching/caching_query.py
b/examples/dogpile_caching/caching_query.py
index f4724fb..fb019cc 100644
--- a/examples/dogpile_caching/caching_query.py
+++ b/examples/dogpile_caching/caching_query.py
@@ -136,7 +136,7 @@ def _key_from_query(query, qualifier=None):
"""
- stmt = query.statement
+ stmt = query.with_labels().statement
compiled = stmt.compile()
params = compiled.params
that's fixed in master right now.
On May 28, 2013, at 1:19 AM, John Anderson <[email protected]> wrote:
> Sorry, re-sending, I accidentally replied directly to Mike:
>
> Here is a small gist that shows how to reproduce it:
>
> https://gist.github.com/sontek/5660624
>
> If you use that along with the caching query stuff in the examples and run it
> you should get the following error:
>
> SAWarning: Column 'date_created' on table <sqlalchemy.sql.expression.Select
> at 0x313f090; Select object> being replaced by another column with the same
> key. Consider use_labels for select() statements.
> SAWarning: Column 'pk' on table <sqlalchemy.sql.expression.Select at
> 0x313f090; Select object> being replaced by another column with the same key.
> Consider use_labels for select() statements.
>
> but if you add _with_labels to the CachingQuery class it will all work as
> expected.
>
>
>
>
> On Monday, May 27, 2013 6:47:37 PM UTC-7, Michael Bayer wrote:
> I use this recipe extensively (and have for several years), can you provide a
> test case that generates that warning?
>
>
> On May 27, 2013, at 9:01 PM, John Anderson <[email protected]> wrote:
>
>> I'm trying to adopt the examples from:
>>
>> https://bitbucket.org/zzzeek/sqlalchemy/src/e2b8c893ca98/examples/dogpile_caching/
>>
>> to work with my code base and so I've copy and pasted the caching_query.py
>> into my project and started doing queries like this:
>>
>>
>> DBSession = scoped_session(
>> sessionmaker(query_cls=query_callable(regions))
>> )
>>
>>
>> def get_user_by_username(session, username, with_profile=True):
>> query = session.query(User).filter(
>> User.username == username
>> ).options(FromCache("default"))
>>
>> if with_profile:
>> query = query.options(
>> joinedload('profile')
>> , RelationshipCache(User.profile)
>> )
>>
>> user = query.one()
>>
>> return user
>>
>>
>>
>> The first problem I see is now its complaining about conflicting column
>> names:
>>
>> /home/sontek/.virtualenvs/notaliens3/src/notaliens.com/eggs/SQLAlchemy-0.8.1-py3.3.egg/sqlalchemy/sql/expression.py:2471:
>> SAWarning: Column 'pk' on table <sqlalchemy.sql.expression.Select at
>> 0x7fdd7af2e2d0; Select object> being replaced by another column with the
>> same key. Consider use_labels for select() statements.
>> self[column.key] = column
>>
>>
>> I was able to fix this by adding _with_labels = True to the CachingQuery
>> code but not sure if that is the best place to do that.
>>
>> Without the caching query it was generating the labels correctly.
>>
>>
>> The only other problem I had with the example was that it is using unicode()
>> which isn't python3 compatible but that was also a pretty easy fix.
>>
>>
>>
>> Thanks for the example! Is there a reason it has to live in examples rather
>> than being a part of SQLAlchemy or a 3rd glue package? It seems to work
>> well
>>
>> --
>> 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?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.