Re: [sqlalchemy] mapper on a temporary class

2021-01-27 Thread Kent Bower
Excellent. As always, thanks very much for your time and answers (let alone awesome software)! On Wed, Jan 27, 2021 at 1:25 PM Mike Bayer wrote: > > > On Tue, Jan 26, 2021, at 9:01 PM, Kent Bower wrote: > > Thanks a ton for your responses. > > Do all the normal column

Re: [sqlalchemy] mapper on a temporary class

2021-01-26 Thread Kent Bower
uld that modify the compiled mappers for the entire process... these are the things running through my head.) On Tue, Jan 26, 2021 at 8:18 PM Mike Bayer wrote: > > > On Tue, Jan 26, 2021, at 7:31 PM, Kent Bower wrote: > > I should have given these details from the get

Re: [sqlalchemy] mapper on a temporary class

2021-01-26 Thread Kent Bower
anyway, or won’t this work? On Tue, Jan 26, 2021 at 6:18 PM Mike Bayer wrote: > > > On Tue, Jan 26, 2021, at 3:16 PM, Kent wrote: > > Question: if I add a mapper to a class that is only needed temporarily, > does using the mapper compile it along side my "normal" mappers

[sqlalchemy] mapper on a temporary class

2021-01-26 Thread Kent
my "main mappers" and gets thrown away when the class is thrown away or is that not possible? Thanks in advance, Kent -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and

Re: [sqlalchemy] connection close() questions

2020-05-14 Thread Kent Bower
ore > warnings or conditions like this. the most important part is getting the > test coverage in so as I refactor for 1.4 / 2.0 the behavioral contract is > maintained. thanks! > > > > On Wed, May 13, 2020, at 1:16 PM, Kent Bower wrote: > > Very good, will do when I find tim

Re: [sqlalchemy] connection close() questions

2020-05-13 Thread Kent Bower
ts > screwed up, the pool will warn and still make sure it does a real > rollback.you should not see this warning however. > > in 2.0, the whole "reset" logic is simplified so that none of this > complexity will be there. > > > > On Wed, May 13, 2020, at 11:5

Re: [sqlalchemy] connection close() questions

2020-05-13 Thread Kent Bower
elease today > > > > On Wed, May 13, 2020, at 11:51 AM, Mike Bayer wrote: > > > > On Wed, May 13, 2020, at 11:39 AM, Kent Bower wrote: > > In this script, conn.close() does *not *call rollback on the > transaction. It isn't just a logging issue as I've verified from the &g

Re: [sqlalchemy] connection close() questions

2020-05-13 Thread Kent Bower
ehaviors of > Connection. So yes I would not be relying upon DBSession.close() as a > means of transaction control if the session is bound to a connection > directly. If the session is bound to a connection I would advise ensuring > that connection is in a transaction on the outside that you ar

[sqlalchemy] connection close() questions

2020-05-13 Thread Kent
more complex, with zope.sqlalchemy & transaction and frameworks; I boiled it down to this script for demo purposes and removed those libraries, making this code look weirder.) Thanks in advance! Kent -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy

[sqlalchemy] Re: recipe advice for special 1:1 relationships

2019-04-04 Thread Kent
Excellent, thanks very much! -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You

[sqlalchemy] Re: recipe advice for special 1:1 relationships

2019-04-04 Thread Kent
Will a.b1 = None issue a delete statement that also contains the WHERE clause to make that safe? (Or, is the delete always by primary key anyway?) -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE:

[sqlalchemy] recipe advice for special 1:1 relationships

2019-04-04 Thread Kent
Thanks! Kent -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message becau

Re: [sqlalchemy] use_ansi inconsistency with relationship's primaryjoin

2017-09-13 Thread Kent
Never mind that last silly 0.7 question. (Your patch is compatible it seems.) (And pretend that you didn't hear any mention of 0.7) Thanks again for your awesome software! Kent On Wednesday, September 13, 2017 at 3:42:55 PM UTC-4, Kent wrote: > > >> dude!it is 2017. get on

Re: [sqlalchemy] use_ansi inconsistency with relationship's primaryjoin

2017-09-13 Thread Kent
w have easy to run Oracle, SQL > Server, etc. databases anywhere I need them so I can quickly confirm > that this works with ansi or not: > > mapper(Rock, rocks_table, > properties={ > 'livingbugs': relationship(Bug, > primaryjoin=and_( >

[sqlalchemy] use_ansi inconsistency with relationship's primaryjoin

2017-09-13 Thread Kent
ot;ON ..." clause instead of the "WHERE". Alternatively, is there a hack I could use to fix the rendered SQL on joinedloads for this particular relationship? Thanks very much in advance! Kent -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlal

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

2017-05-10 Thread Kent Bower
t;> >> 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 marked "expired". >> >> >> On 05/10/2017 01:38 PM, Kent wrot

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

2017-05-10 Thread Kent Bower
lace, so it needs to be marked "expired". > > > On 05/10/2017 01:38 PM, Kent wrote: > >> 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.

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

2017-05-10 Thread Kent
, 2017 at 12:55:45 PM UTC-4, Mike Bayer wrote: > > 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 &g

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

2017-05-10 Thread Kent Bower
ike...@zzzcomputing.com> wrote: > 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

[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

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

2017-05-10 Thread Kent
.dict" ? Just wanted someone to look that code over again. 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 > read-o

Re: [sqlalchemy] Filters on specific tables of concrete polymorphic union

2017-04-13 Thread Kent
Awesome! I like the second approach better for the exact same reasons. Thanks so much! Kent On Thursday, April 13, 2017 at 1:50:40 PM UTC-4, Mike Bayer wrote: > > > it has nothing to do with joined table inheritance, in your example, > your base mapper is al

Re: [sqlalchemy] Filters on specific tables of concrete polymorphic union

2017-04-13 Thread Kent
-4, Mike Bayer wrote: > > > > On 04/13/2017 10:24 AM, Kent wrote: > > Suppose we have the documentation's example of *Concrete Table > > Inheritance, *where > > > > session.query(Employee).all() > > > > > > pr

[sqlalchemy] Filters on specific tables of concrete polymorphic union

2017-04-13 Thread Kent
)) AS manager_data, engineers.name AS name, engineers.engineer_info AS engineer_info, 'engineer' AS type FROM engineers ) AS pjoin Is there a way to accomplish this? Thanks in advance, Kent -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post

Re: [sqlalchemy] inspect a scalar relationship property when it is loaded

2016-10-28 Thread Kent Bower
n Fri, Oct 28, 2016 at 11:21 AM, mike bayer <mike...@zzzcomputing.com> wrote: > > > On 10/28/2016 10:48 AM, Kent wrote: > >> @validates and 'set' attribute events will only fire when the /user/ >> sets a property (setattr), not when initially loaded by the orm. >>

[sqlalchemy] inspect a scalar relationship property when it is loaded

2016-10-28 Thread Kent
@validates and 'set' attribute events will only fire when the *user* sets a property (setattr), not when initially loaded by the orm. Is there a way to intercept (for inspection) a scalar relationship property instance when it is loaded? I don't think the 'load' event will work because I

Re: [sqlalchemy] suppress echo of INSERT/UPDATE large binary data

2016-08-18 Thread Kent Bower
I attempted to search for such an enhancement but obviously failed to find it. Patching the changeset in was fairly straightforward. Thanks very much Jonathan and Mike!! On Wed, Aug 17, 2016 at 5:41 PM, Mike Bayer <mike...@zzzcomputing.com> wrote: > > > On 08/17/2016 01:25

[sqlalchemy] suppress echo of INSERT/UPDATE large binary data

2016-08-17 Thread Kent
Generally, echo=True for log level of INFO is very helpful for log files. But on INSERT/UPDATE of a Binary column (at least with Oracle, BLOB) it sure would be nice to skip the logging of the sometimes massive binary data. Is this possible? Thanks, Kent -- You received this message because

Re: [sqlalchemy] Help with a custom "seconds_interval()" construct

2016-05-31 Thread Kent Bower
> > > On 05/28/2016 09:44 AM, Kent wrote: > >> I'm interested in being able to use second time intervals on PostgreSQL, >> Oracle 8 /and /modern Oracle versions, agnostically. >> >> The native python timedelta works great for the postgres and cx_Oracle &g

[sqlalchemy] Help with a custom "seconds_interval()" construct

2016-05-28 Thread Kent
elta as bind param from datetime import timedelta td = timedelta(seconds=element.seconds) *return ...???* Can anyone help me with the else: above to use the native python timedelta as a bind param? (Or trash it completely if there is a better strategy?) Much thanks in advanc

Re: [sqlalchemy] Guaranteeing same connection for scoped session

2016-04-14 Thread Kent Bower
Yeah, it seems to me that if you pass a *specific connection* to a sessionmaker for some (whatever) reason, that sessionmaker shouldn't ever silently take a different one. I'll need to work on detecting or sabotaging new connections from a sessionmaker which was passed a specific connection. (I

Re: [sqlalchemy] Guaranteeing same connection for scoped session

2016-04-13 Thread Kent Bower
ah either don't > call that , or set up the connection immediately on the next session. > > On Wednesday, April 13, 2016, Kent Bower <k...@bowermail.net > <javascript:_e(%7B%7D,'cvml','k...@bowermail.net');>> wrote: > >> About a year ago you helped me ensure my

Re: [sqlalchemy] Guaranteeing same connection for scoped session

2016-04-13 Thread Kent Bower
was called. Is there a way to guarantee this? See attached script that fails on version 1.0.12 Is this the intended behavior when sessionmaker has a specific connection as bind? On Mon, Mar 23, 2015 at 12:40 PM, Michael Bayer <mike...@zzzcomputing.com> wrote: > > > Kent <

Re: [sqlalchemy] Guaranteeing same connection for scoped session

2015-03-24 Thread Kent
Thanks very much Mike. On Monday, March 23, 2015 at 12:40:46 PM UTC-4, Michael Bayer wrote: Kent jkent...@gmail.com javascript: wrote: In cases where we interact with the database session (a particular Connection) to, for example, obtain an application lock which is checked out from

[sqlalchemy] Guaranteeing same connection for scoped session

2015-03-23 Thread Kent
In cases where we interact with the database session (a particular Connection) to, for example, obtain an application lock which is checked out from database for the lifetime of the database session (not just the duration of a transaction), it is important that I guarantee future scoped

Re: [sqlalchemy] Database session variables with connection pooling

2015-03-09 Thread Kent
) before issuing the DBMS_SESSION.SET_CONTEXT(...). But, once I know that within before_cursor_execute, can I (recursively) issue an conn.execute() for that statement safely or will it affect the original execute? On Saturday, March 7, 2015 at 6:38:08 PM UTC-5, Michael Bayer wrote: Kent jkent

Re: [sqlalchemy] Database session variables with connection pooling

2015-03-09 Thread Kent
Perfect, thanks much! On Saturday, March 7, 2015 at 6:38:08 PM UTC-5, Michael Bayer wrote: Kent jkent...@gmail.com javascript: wrote: I'm implementing database session variables (in Oracle, DBMS_SESSION.SET_CONTEXT(...)), in order to be able to set (from sqlalchemy) and retrieve (from

[sqlalchemy] Database session variables with connection pooling

2015-03-07 Thread Kent
to record the fact that I've set the database session's variables on an object (such as connection_record) so that subsequent requests can detect whether it needs to be reset. Will connection_record correspond to a database session? Thanks in advance for any advice here. Kent -- You

[sqlalchemy] Oracle use_ansi=False inner join problem on inline views

2015-01-21 Thread Kent
WHERE anon_1.productid*(+)* = products.productid ORDER BY anon_1.siteid Interestingly, use-ansi=True correctly renders LEFT OUTER JOIN in 0.8.7 but it fails to render as an outer join with use-ansi=False. Thanks for you time and exceptional software, Kent -- You received this message because

Re: [sqlalchemy] Oracle use_ansi=False inner join problem on inline views

2015-01-21 Thread Kent
for security issues back to 0.8. there’s a new website section coming soon that will show this stuff. Kent jkent...@gmail.com javascript: wrote: Here it is: commit 85368d25ed158c85bd19f4a63400884ab1cda26a Author: Mike Bayer m... Date: Sat Jun 8 18:54:14 2013 -0400

Re: [sqlalchemy] Oracle use_ansi=False inner join problem on inline views

2015-01-21 Thread Kent
, January 21, 2015 at 1:13:21 PM UTC-5, Michael Bayer wrote: Kent jkent...@gmail.com javascript: wrote: Mike, When using use_ansi=False for Oracle (8) in conjunction with joinedload-ing an inline view property, SQLAlchemy-0.8.7 renders an inner join instead of an outer join. This has

Re: [sqlalchemy] Oracle use_ansi=False inner join problem on inline views

2015-01-21 Thread Kent
Hmmm 0.7 is missing expression.FromGrouping... I imagine that is a big deal, isn't it, like not really patchable? On Wednesday, January 21, 2015 at 3:11:29 PM UTC-5, Kent wrote: Here it is: commit 85368d25ed158c85bd19f4a63400884ab1cda26a Author: Mike Bayer m... Date: Sat Jun 8 18

Re: [sqlalchemy] DISTINCT with LIMIT problem

2013-05-31 Thread Kent
, 2013, at 6:06 PM, Kent jkentbo...@gmail.com wrote: Thank you, I'll try that, but quick concern: I specifically skipped trying to use .subquery() because the docs say Eager JOIN generation within the query is disabled. Doesn't that mean I won't get my joinedload() results from the inner query

Re: [sqlalchemy] DISTINCT with LIMIT problem

2013-05-31 Thread Kent
with the EmailAddress table to strictly filter results. Employee records: idname 1 kent 2 charlie EmailAddress records: empid address === 1k...@mymail.goo 1k...@mymail.goo 1k...@gmail.de 2char...@gmail.de

[sqlalchemy] DISTINCT with LIMIT problem

2013-05-30 Thread Kent
statement here so sqlalchemy won't translate result rows into object instances. Can you point me in the right direction for one of these 2 solutions, please? Many thanks, Kent -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from

Re: [sqlalchemy] DISTINCT with LIMIT problem

2013-05-30 Thread Kent
eager join disabled? On 5/30/2013 5:54 PM, Michael Bayer wrote: On May 30, 2013, at 5:19 PM, Kent jkentbo...@gmail.com mailto:jkentbo...@gmail.com wrote: Solution A: Group by all columns (yielding the same effect as distinct), but which makes the window analytical function

[sqlalchemy] Undefer Hybrid Attributes

2013-03-07 Thread Kent
I notice that Hybrid Attributes don't show up as mapper properties (since they are class wide instead of mapper specific, I suppose). I couldn't find documentation on whether I can undefer these? Or can I create a synonym or column_property from a hybrid attribute in the mapper? -- You

[sqlalchemy] Re: Undefer Hybrid Attributes

2013-03-07 Thread Kent
I suppose what I'm really after is a column_property (for class level) and plain descriptor (for instance level), which is exactly what Hybrid attributes are meant to be, but I wanted them to be part of the mapper and undeferred in some cases. On Thursday, March 7, 2013 11:36:37 AM UTC-5, Kent

Re: [sqlalchemy] Undefer Hybrid Attributes

2013-03-07 Thread Kent Bower
That makes sense, Thanks, Kent On Mar 7, 2013, at 12:09 PM, Michael Bayer mike...@zzzcomputing.com wrote: The hybrid attribute is a Python function that invokes when it's called. So it doesn't make sense for it to be a column property since there is no attribute to be populated

[sqlalchemy] query of existing object won't refresh values (even when FOR UPDATE)

2013-03-05 Thread Kent
By design, when a query() fetches an existing object, it doesn't refresh the values unless populate_existing() is included with the query. The documentation for populate_existing() states it isn't meant for general purpose. Occasionally, however, objects need to be selected FOR UPDATE,

[sqlalchemy] Re: query of existing object won't refresh values (even when FOR UPDATE)

2013-03-05 Thread Kent
I imagine this gets ugly when autoflush is disabled... perhaps that is why it requires populate_existing()? On Tuesday, March 5, 2013 10:00:36 AM UTC-5, Kent wrote: By design, when a query() fetches an existing object, it doesn't refresh the values unless populate_existing() is included

Re: [sqlalchemy] query of existing object won't refresh values (even when FOR UPDATE)

2013-03-05 Thread Kent
is certainly something doable (because I would hope very much that anyone using this method has read the documentation carefully). On Mar 5, 2013, at 10:00 AM, Kent jkentbo...@gmail.com mailto:jkentbo...@gmail.com wrote: By design, when a query() fetches an existing object, it doesn't refresh

[sqlalchemy] orm_exc.NoResultFound safe with autoflush?

2013-02-08 Thread Kent
We often use this pattern: try: session.query().one() except orm_exc.NoResultFound: gracefully deal with it If the query() execution causes an autoflush, I just want to make sure that an autoflush will never raise orm_exc.NoResultFound, or we could be catching the wrong error. Were that

[sqlalchemy] RE: 'Hand Coded Applications with SQLAlchemy' video

2012-11-30 Thread Kent Tenney
to evolve quickly, I'm using trunk. Thanks, Kent -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com

Re: [sqlalchemy] changes flushed for expunged relationships

2012-10-18 Thread Kent
Thank you for the clarifications. On 10/18/2012 11:43 AM, Michael Bayer wrote: On Oct 17, 2012, at 9:55 PM, Kent wrote: The attached script fails with sqlalchemy.exc.InvalidRequestError: Instance 'Bug at 0x1e6f3d10' has been deleted. Use the make_transient() function to send this object

Re: [sqlalchemy] changes flushed for expunged relationships

2012-10-18 Thread Kent
On Thursday, October 18, 2012 11:43:50 AM UTC-4, Michael Bayer wrote: On Oct 17, 2012, at 9:55 PM, Kent wrote: The attached script fails with sqlalchemy.exc.InvalidRequestError: Instance 'Bug at 0x1e6f3d10' has been deleted. Use the make_transient() function to send this object back

[sqlalchemy] changes flushed for expunged relationships

2012-10-17 Thread Kent
this scenario since in a rare case, it presents. Thanks very much! Kent -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/6oYSFMbpnEsJ. To post to this group, send

Re: [sqlalchemy] live access to postgis database to use in ExtJS, OpenLayers, etc

2012-10-03 Thread Kent Tenney
It sounds like you are trying to do at least 6 quite complicated things all at once, without really understanding any of them. This will not be easy. Sigh. The story of my life in one sentence. On Tue, Oct 2, 2012 at 8:43 AM, Simon King si...@simonking.org.uk wrote: On Mon, Oct 1, 2012 at 11:38

[sqlalchemy] safe usage within before_update/before_insert events

2012-09-12 Thread Kent
You've mentioned multiple times (to me and others) that some operations, such as reaching across relationships or loading relationships from within a before_update Mapper event is not safe. - I understand this is safe from within Session event before_flush(), correct? - We mentioned

[sqlalchemy] Apparently redundant subqueryloads with single table inheritance

2012-06-05 Thread Kent
for the session.query().get(), but I there are 11 queries instead, most of them redundant. Any ideas? Thanks, Kent -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/vC69eQMhv10J

Re: [sqlalchemy] Apparently redundant subqueryloads with single table inheritance

2012-06-05 Thread Kent Bower
Thank you! On 6/5/2012 4:41 PM, Michael Bayer wrote: On Jun 5, 2012, at 4:21 PM, Kent wrote: I am subquery loading some related properties for a polymorphic inheritance use case similar to the script attached. SQLA seems to be issuing several extra queries that I didn't expect and don't

[sqlalchemy] overriding inherited mapper properties supported?

2012-05-17 Thread Kent
Suppose I am using single table polymorphic inheritance like the docs Employee/Manager/Engineer example. I have a relationship that I want to have a different cascade or loading strategy for, depending on the mapper. Can I inherit from the base mapper and override the property, like this:

Re: [sqlalchemy] sqlalchemy supports INSERT INTO ... (SELECT .. ) ?

2012-03-30 Thread Kent Bower
, 2012, at 6:05 PM, Kent wrote: Couldn't find answer in docs, does sqlalchemy support: INSERT INTO ... (SELECT .. ) instead of INSERT INTO ... VALUES... -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https

Re: [sqlalchemy] sqlalchemy supports INSERT INTO ... (SELECT .. ) ?

2012-03-30 Thread Kent Bower
')) or something like that. Maybe people have suggestions. On Mar 30, 2012, at 6:43 PM, Kent Bower wrote: Thanks for pointing me there. As an aside, the recipe would be more bulletproof if it specified the columns (order). Currently, it assumes sqlalchemy knows the order of the columns in the database

[sqlalchemy] Single table inheritance

2012-03-21 Thread Kent
Hoping for advice: I'm using sqlalchemy against a legacy application's database design, most of which isn't in my control. I have a situation where single table inheritance should work beautifully but there is one catch: of the 7 polymorphic sub classes, there is one which is allowed to

Re: [sqlalchemy] Single table inheritance

2012-03-21 Thread Kent Bower
That will work for me, thanks! P.S. make a note that the doc statement that it will be a future release should be updated. On 3/21/2012 10:04 AM, Michael Bayer wrote: also polymorphic_on can be any SQL expression in 0.7, like a CASE statement if you wanted. -- You received this message

[sqlalchemy] Half merge/save cascade support for M:N relationships

2012-02-29 Thread Kent
I suspect this doesn't interest you so much, and no offense taken if not, but have you ever considered supporting the idea of a half merge/save-update cascade for many to many relationships? The use case is where I want to merge/save-update to the secondary table only (collection status), but

Re: [sqlalchemy] Half merge/save cascade support for M:N relationships

2012-02-29 Thread Kent Bower
iPhone On Feb 29, 2012, at 8:55 AM, Kent jkentbo...@gmail.com mailto:jkentbo...@gmail.com wrote: I suspect this doesn't interest you so much, and no offense taken if not, but have you ever considered supporting the idea of a half merge/save-update cascade for many to many relationships? The use

[sqlalchemy] most straightforward way to revert some column changes

2012-02-28 Thread Kent
Is there a simple way to revert all columns back to their committed state (some columns may be synonyms), or do I need to loop through mapper.iterate_properties, get the ColumnProperty ones, make sure they aren't aliases (prop.columns[0] is Column) and use setattr() to set the value back to the

[sqlalchemy] Re: most straightforward way to revert some column changes

2012-02-28 Thread Kent
On Feb 28, 5:39 pm, Michael Bayer mike...@zzzcomputing.com wrote: oh also you might want to use attributes.set_committed_state instead of setattr() so that the history is cleared. 1) What do you mean? setattr() also clears the history if you set it back to what it used to be... right? 2)

[sqlalchemy] Re: session.query().get() is unsupported during flush for getting an object that was just added?

2012-02-06 Thread Kent
On Feb 1, 3:17 pm, Kent jkentbo...@gmail.com wrote: If the value is based on what's already been INSERTed for previous rows, I'd emit a SQL statement to get at the value.If it's based on some kind of natural consideration that isn't dependent on the outcome of an INSERT statement

[sqlalchemy] Re: session.query().get() is unsupported during flush for getting an object that was just added?

2012-02-01 Thread Kent
If the value is based on what's already been INSERTed for previous rows, I'd emit a SQL statement to get at the value.If it's based on some kind of natural consideration that isn't dependent on the outcome of an INSERT statement, then you can do the looping above within the

[sqlalchemy] expunge cascade behavior change

2012-01-31 Thread Kent Bower
as previously and if that was considered a bug, etc. Thanks, Kent -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr

[sqlalchemy] session.query().get() is unsupported during flush for getting an object that was just added?

2012-01-26 Thread Kent Bower
your input and thoughts. Thanks, Kent -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more

Re: [sqlalchemy] session.query().get() is unsupported during flush for getting an object that was just added?

2012-01-26 Thread Kent
, which is very good to understand more clearly. Thanks. On 1/26/2012 12:06 PM, Michael Bayer wrote: On Jan 26, 2012, at 11:28 AM, Kent Bower wrote: I think I understand why, during a flush(), if I use session.query().get() for an item that was just added during this flush, I don't get

Re: [sqlalchemy] session.query().get() is unsupported during flush for getting an object that was just added?

2012-01-26 Thread Kent
, meaning it would look a lot like before_update. But looping through .new, .dirty, and .deleted is how to do it for now. On Jan 26, 2012, at 12:12 PM, Kent wrote: Fair enough. I had enough understanding of what must be going on to know flush isn't straightforward, but I'm still glad I asked

[sqlalchemy] backrefs

2012-01-26 Thread Kent
Is there a straightforward way to determine if a RelationshipProperty has a corresponding reverse (backref)? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this

[sqlalchemy] Re: backrefs

2012-01-26 Thread Kent
I assume the non public property._reverse_property is just what I'm looking for. :) On Jan 26, 2:06 pm, Kent jkentbo...@gmail.com wrote: Is there a straightforward way to determine if a RelationshipProperty has a corresponding reverse (backref)? -- You received this message because you

[sqlalchemy] try: except KeyError:

2012-01-25 Thread Kent
At some point you changed the InstrumentedAttribute.get() method from try: return dict_[self.key] except KeyError: ... To this: 432 - def get(self, state, dict_, passive=PASSIVE_OFF): 433 Retrieve a value from the given object. 434 435 If a callable is

[sqlalchemy] c extensions built?

2012-01-12 Thread Kent
What is the easiest way to confirm that my installation has compiled/ is using the c extensions? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send

Re: [sqlalchemy] c extensions built?

2012-01-12 Thread Kent Bower
Yeah, just the two cresultproxy.so and cprocessors.so, right? On 1/12/2012 3:34 PM, Michael Bayer wrote: when you do the setup.py the log messages say so. Otherwise you'd look where sqlalchemy was installed and check if you see .so files. On Jan 12, 2012, at 12:35 PM, Kent wrote: What

Re: [sqlalchemy] Re: 0.7 event migration

2012-01-10 Thread Kent Bower
funny story, here's where it was added: http://www.sqlalchemy.org/trac/ticket/1910 which is essentially your ticket ! :) I just double checked and I had patched in rfde41d0e9f70 http://www.sqlalchemy.org/trac/changeset/fde41d0e9f70/. Is there another commit that went against 1910? For

[sqlalchemy] Re: 0.7 event migration

2012-01-10 Thread Kent
See http://www.sqlalchemy.org/trac/ticket/2372 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com.

[sqlalchemy] Re: 0.7 event migration

2012-01-10 Thread Kent
Mike, Old code: == def visit_bindparam(bindparam): if bindparam.key in bind_to_col: bindparam.value = lambda: mapper._get_state_attr_by_column( state, dict_,

Re: [sqlalchemy] Re: 0.7 event migration

2012-01-10 Thread Kent Bower
Thank you very much! On 1/10/2012 11:47 AM, Michael Bayer wrote: Code wasn't covered and is a regresssion, fixed in rd6e321dc120d. On Jan 10, 2012, at 10:58 AM, Kent wrote: Mike, Old code: == def visit_bindparam(bindparam

[sqlalchemy] More 0.7 migration pains

2012-01-10 Thread Kent
After 0.7.5 migration, I'm sometimes hitting an issue from within merge(). unitofwork.py def track_cascade_events(descriptor, prop): ... def set_(state, newvalue, oldvalue, initiator): # process save_update cascade rules for when an instance # is attached to another instance

[sqlalchemy] Re: 0.7 event migration

2012-01-09 Thread Kent
i guess the patch is interacting with that load_on_pending stuff, which I probably added for you also. It would be nice to really work up a new SQLAlchemy feature: detached/transientobject loading document that really describes what it is we're trying to do here.If you were to write

Re: [sqlalchemy] Re: 0.7 event migration

2012-01-09 Thread Kent Bower
On 1/9/2012 2:33 PM, Michael Bayer wrote: On Jan 9, 2012, at 2:30 PM, Kent wrote: i guess the patch is interacting with that load_on_pending stuff, which I probably added for you also. It would be nice to really work up a new SQLAlchemy feature: detached/transientobject loading document

Re: [sqlalchemy] Re: 0.7 event migration

2012-01-09 Thread Kent Bower
On 1/9/2012 5:33 PM, Michael Bayer wrote: On Jan 9, 2012, at 2:36 PM, Kent Bower wrote: that means some of the columns being linked to the foreign keys on the target are None. If you want your lazyload to work all the attributes need to be populated. If you're hitting the get committed

[sqlalchemy] 'TypeError: expecting numeric data' is only raised for do_executemany

2012-01-03 Thread Kent
The statements that are executed as a single statement make no such check (and the database engine correctly translates a string to integer), but cursor.executemany checks type: lib/sqlalchemy/engine/default.py, line 327, in do_executemany cursor.executemany(statement, parameters) TypeError:

[sqlalchemy] Re: 'TypeError: expecting numeric data' is only raised for do_executemany

2012-01-03 Thread Kent
Oh. Makes sense. Then the only reason I'm starting to hit this is that you've optimized the orm to use executemany() more often, correct? On Jan 3, 3:09 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 3, 2012, at 1:58 PM, Kent wrote: The statements that are executed as a single

Re: [sqlalchemy] Re: 0.7 event migration

2011-12-28 Thread Kent
On 12/27/2011 5:34 PM, Michael Bayer wrote: On Dec 27, 2011, at 5:21 PM, Kent wrote: So see what happens if you, for the moment, just monkeypatch over orm.session._state_session to do a lookup in a global context if state.session_id isn't set. If that solves the problem of I want detached

[sqlalchemy] InvalidRequestError: get() can only be used against a single mapped class.

2011-12-28 Thread Kent
Was it your intention to no longer allow this type of query().get()? session.query(cls.orderid).get(orderid) I get InvalidRequestError: get() can only be used against a single mapped class. but the wording is such that I'm not sure you intended to limit that use case (there is only a single

[sqlalchemy] Re: InvalidRequestError: get() can only be used against a single mapped class.

2011-12-28 Thread Kent
On Dec 28, 12:07 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 28, 2011, at 11:34 AM, Kent wrote: Was it your intention to no longer allow this type of query().get()? session.query(cls.orderid).get(orderid) it was !   yes. I get InvalidRequestError: get() can only

[sqlalchemy] Re: InvalidRequestError: get() can only be used against a single mapped class.

2011-12-28 Thread Kent
in fact, I modified our Query class after .first() was being abused out of laziness: def first(self): raise ProgrammingError(Never use .first(); please use .get() or .one()\n .one() makes sure there is only one return and .get() returns None if doesn't exist.\n

[sqlalchemy] Re: 0.7 event migration

2011-12-27 Thread Kent
On Dec 26, 5:12 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 26, 2011, at 1:50 PM, Kent wrote: Yes, a nice simplification. I'm using it to lazyload attributes for objects that aren't in a session.  I'm not sure if you pointed me there, I think I found it myself, but you

[sqlalchemy] SAWarning: Object of type Discount not in session, add operation along 'OrderDetailDiscount.discount' won't proceed

2011-12-27 Thread Kent
In http://www.sqlalchemy.org/trac/changeset/7025%3A0a6576abea5b#file1 you added a warning that I'm hitting now. 'when save-update cascade is disabled, or the target object is otherwise not present in the session, and collection/scalar changes have taken place. A warning is emitted describing the

Re: [sqlalchemy] SAWarning: Object of type Discount not in session, add operation along 'OrderDetailDiscount.discount' won't proceed

2011-12-27 Thread Kent
On 12/27/2011 2:34 PM, Michael Bayer wrote: On Dec 27, 2011, at 1:51 PM, Kent wrote: In http://www.sqlalchemy.org/trac/changeset/7025%3A0a6576abea5b#file1 you added a warning that I'm hitting now. 'when save-update cascade is disabled, or the target object is otherwise not present

[sqlalchemy] Re: 0.7 event migration

2011-12-27 Thread Kent
So see what happens if you, for the moment, just monkeypatch over orm.session._state_session to do a lookup in a global context if state.session_id isn't set.  If that solves the problem of I want detached objects to load stuff, for you and everyone else who wants this feature, then

Re: [sqlalchemy] 0.7 event migration

2011-12-26 Thread Kent
summarize how this is meant to work now? (I think the doc string is wrong now??) On 12/25/2011 10:31 AM, Michael Bayer wrote: yes a few change names, reconstruct_instance, init_instance, init_failed. On Dec 24, 2011, at 7:42 PM, Kent Bower wrote: Right. And reconstruct_instance

  1   2   3   4   >