diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-05 21:01:21 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-03-05 21:01:21 +0000 |
commit | 9446e490cb14d456c96b4731993e2a965a090b1a (patch) | |
tree | 193545cacdfd7f452d58c81e7f2e28f788f58d74 /lib/sqlalchemy/engine.py | |
parent | 9c4f3c0480f54e08b3aa2800ed76e89f957f8131 (diff) | |
download | sqlalchemy-9446e490cb14d456c96b4731993e2a965a090b1a.tar.gz |
got mapper to receive the onupdates after updating an instance (also properly receives defaults on inserts)...
Diffstat (limited to 'lib/sqlalchemy/engine.py')
-rw-r--r-- | lib/sqlalchemy/engine.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine.py b/lib/sqlalchemy/engine.py index 3703169fa..5f681d39e 100644 --- a/lib/sqlalchemy/engine.py +++ b/lib/sqlalchemy/engine.py @@ -484,20 +484,33 @@ class SQLEngine(schema.SchemaEngine): self.context.last_inserted_ids = None else: self.context.last_inserted_ids = last_inserted_ids + self.context.last_inserted_params = param elif getattr(compiled, 'isupdate', False): if isinstance(parameters, list): plist = parameters else: plist = [parameters] drunner = self.defaultrunner(proxy) + self.context.lastrow_has_defaults = False for param in plist: for c in compiled.statement.table.c: if c.onupdate is not None and (not param.has_key(c.name) or param[c.name] is None): value = drunner.get_column_onupdate(c) if value is not None: param[c.name] = value - + self.context.last_updated_params = param + + def last_inserted_params(self): + """returns a dictionary of the full parameter dictionary for the last compiled INSERT statement, + including any ColumnDefaults or Sequences that were pre-executed. this value is thread-local.""" + return self.context.last_inserted_params + def last_updated_params(self): + """returns a dictionary of the full parameter dictionary for the last compiled UPDATE statement, + including any ColumnDefaults that were pre-executed. this value is thread-local.""" + return self.context.last_updated_params def lastrow_has_defaults(self): + """returns True if the last row INSERTED via a compiled insert statement contained PassiveDefaults, + indicating that the database inserted data beyond that which we gave it. this value is thread-local.""" return self.context.lastrow_has_defaults def pre_exec(self, proxy, compiled, parameters, **kwargs): |