Re: [sqlalchemy] a few questions on transactional events

2017-05-10 Thread Jonathan Vanasco
On Wednesday, May 10, 2017 at 8:09:22 PM UTC-4, Mike Bayer wrote: > > no return value needed > perfect > you mean, the commit() method itself how long does that take? You'd > probably do a time.time() check before and after calling the method (or > use timeit.timeit to do the same). >

Re: [sqlalchemy] a few questions on transactional events

2017-05-10 Thread mike bayer
On 05/10/2017 07:55 PM, Jonathan Vanasco wrote: I have a few basic questions on the "transactional" events as I try to extend pyramid's logging system to grab them. 1. do the events need to return anything, or can they just sit there and be dumb? for example:

Re: [sqlalchemy] Re: deferred column_properties should probably not be expired unless they were already loaded

2017-05-10 Thread Kent Bower
Thanks very much! On Wed, May 10, 2017 at 2:24 PM, mike bayer wrote: > this is all patched in 1.2, your original test works too. > > The fix here is a little too intricate for 1.1 right now as this is a very > long-standing bug(goes back to 0.7 at least and

Re: [sqlalchemy] Re: deferred column_properties should probably not be expired unless they were already loaded

2017-05-10 Thread mike bayer
this is all patched in 1.2, your original test works too. The fix here is a little too intricate for 1.1 right now as this is a very long-standing bug (goes back to 0.7 at least and probably further) and 1.1 is getting near maintenance mode. On 05/10/2017 01:48 PM, mike bayer wrote:

Re: [sqlalchemy] Re: deferred column_properties should probably not be expired unless they were already loaded

2017-05-10 Thread mike bayer
On 05/10/2017 02:00 PM, Kent Bower wrote: If never present in __dict__, why does it need to be marked as expired after an insert or update? If not in __dict__ and referenced, isn't won't it load as whether or not it is marked as expired? if: 1. an attribute is a normal column-oriented

Re: [sqlalchemy] Re: deferred column_properties should probably not be expired unless they were already loaded

2017-05-10 Thread Kent Bower
If never present in __dict__, why does it need to be marked as expired after an insert or update? If not in __dict__ and referenced, isn't won't it load as whether or not it is marked as expired? On Wed, May 10, 2017 at 1:48 PM, mike bayer wrote: > nevermind, the

Re: [sqlalchemy] Re: deferred column_properties should probably not be expired unless they were already loaded

2017-05-10 Thread mike bayer
nevermind, the issue is at https://bitbucket.org/zzzeek/sqlalchemy/issues/3984/deferred-column_property-gets-set-to the fix is not as obvious as that, that particular check is assuming a column_property() where its value was never present in __dict__ in the first place, so it needs to be

Re: [sqlalchemy] Re: deferred column_properties should probably not be expired unless they were already loaded

2017-05-10 Thread Kent
The regular columns seem to expire and reload properly without issue. (Is that what you're asking?) You want me to submit a PR changing: if p.expire_on_flush or p.key *not *in state.dict to if p.expire_on_flush *and *p.key in state.dict ? (If so, which branch?) On Wednesday, May 10,

Re: [sqlalchemy] Re: deferred column_properties should probably not be expired unless they were already loaded

2017-05-10 Thread Kent Bower
The regular columns seem to expire and reload properly without issue. (Is that what you're asking?) You want me to submit a PR changing: if p.expire_on_flush or p.key *not *in state.dict to if p.expire_on_flush *and *p.key in state.dict ? On Wed, May 10, 2017 at 12:55 PM, mike bayer

Re: [sqlalchemy] Re: deferred column_properties should probably not be expired unless they were already loaded

2017-05-10 Thread mike bayer
so you can confirm this is only for custom SQL + column_property(), not a regular column right? definitely a bug for 1.2 if you can post it up On 05/10/2017 12:37 PM, Kent wrote: I'm thinking that should be *"if p.expire_on_flush and p.key in state.dict"* On Wednesday, May 10, 2017 at

Re: [sqlalchemy] Using sql expression to update a column from another table's column

2017-05-10 Thread mike bayer
we don't support the INNER JOIN keyword here, use an implicit join: s.query(A).filter(A.id == B.id).filter(B.typ == '2').update({A.str: func.concat(A.str, B.str)}, synchronize_session=False) On 05/10/2017 11:30 AM, Shane Carey wrote: Given the following declarative schema, how can I

[sqlalchemy] Re: deferred column_properties should probably not be expired unless they were already loaded

2017-05-10 Thread Kent
I'm thinking that should be *"if p.expire_on_flush and p.key in state.dict"* On Wednesday, May 10, 2017 at 11:35:30 AM UTC-4, Kent wrote: > > deferred column_properties may be less-efficient subquery selects (and > thus marked deferred). When a flush occurs that updates an object, any >

[sqlalchemy] Re: deferred column_properties should probably not be expired unless they were already loaded

2017-05-10 Thread Kent
Another question surrounding this: in persistence.py: def _finalize_insert_update_commands(...) if mapper._readonly_props: readonly = state.unmodified_intersection( [p.key for p in mapper._readonly_props if p.expire_on_flush or

[sqlalchemy] Using sql expression to update a column from another table's column

2017-05-10 Thread Shane Carey
Given the following declarative schema, how can I generate the UPDATE statement? I am using MySQL class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) str = Column(String(16), nullable=False) bs = relationship(B) class B(Base): __tablename__ = 'b'