I think option #2 with a default is the way to go (see the implementation of auto_identity_insert for how default behavior is done).
I would suggest to default to scope_identity(), which is as you say, safer and is available for most installations, but allow a connection level variable to allow MSSQL v7 users and earlier to still play. Rick On 3/7/07, Tim Golden <[EMAIL PROTECTED]> wrote: > > > Rick Morrison wrote: > > OK, I replied to the other thread already, which is really the same > issue. > > See my response there about backward-compatibility. > > > > At any rate, we could make it a connection variable like > > auto_identity_insert. Patches welcome. > > I'm happy to provide a patch. Not sure about the connection > variable. Ah, I see, you mean because of backwards compat. > But isn't the problem that if we just leave the @@IDENTITY > as now, it's a danger waiting to happen, especially if the > returned id happens to be a valid id for the table you > *think* it's for? > > Not really sure what to offer here: > > 1) I can provide a patch, replacing @@IDENTITY by SCOPE_IDENTITY > throughout. > > 2) I can provide a patch allowing connection-level determination > of whether @@IDENTITY or SCOPE_IDENTITY is to be used. (Which > assumes the client module knows what that's about). > > 3) I can provide a patch which attempts to work out which > one would be allowed from some DB context (or just trying > it to see!) > > The problem with (1) is that, if Rick's right, it won't > work with MSSQL <= 7. The problem with any of (2) or (3) > where @@IDENTITY ends up being used is that we might be > silently and dangerously returning wrong data. > > TJG > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---