>> I hate to disagree here, and I can see what you're getting at, but  
>> honestly, the "INSERT on save()" approach is exactly the naive active- 
>> record-like pattern that SQLAlchemy's ORM was designed to get away from.
>>
>> The way the unit of work functions, we dont generate ids until a flush  
>> occurs.  Flushes dont occur unless you say flush(), or if you have  
> 
> I'm not saying flush on save. I'm saying flush at the last possible 
> moment (which is what it does now) but I want "last possible moment" to 
> include "program tried to access a database-generated field"
> 
> s1 = Something('foo1')
> session.save(s1)
> s2 = Something('foo2')
> session.save(s2)
> # Nothing flushed yet
> s3 = Something('foo3')
> session.save(s3)
> url_for_foo = "/something?id=%d" % s3.id
> # s3 should be flushed, nothing else though (since s3.id was accessed)

Can you suggest other alternatives for the above use case? Having to 
call flush before doing anything that might require the ID seems 
excessive and too low-level for code like that.

I know for a fact that Hibernate does it this way (not that sqlalchemy 
has to do everything Hibernate does), and I can't imagine a use case 
where doing what's needed to retrieve database-generated fields on an 
as-needed basis would be considered incorrect behavior.

I think what I'm asking for can be summarized this way:

"As far as the application is concerned, objects in the Pending and 
Persistent states should function identically."

(it's possible that this feature would be difficult to implement, in 
which case that's a good answer and maybe it can go on to a far-off 
wishlist, or I can try to implement it or something, I just don't see a 
way for it to be considered incorrect behavior)

Thanks,

-Adam Batkin

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to