diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-12-16 07:18:27 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-12-16 07:18:27 +0000 |
commit | 6cdba110a49b701e36f93d82e8772d1909385175 (patch) | |
tree | c1b96732b7e8241db9d5a2262676db140d9f7030 /lib/sqlalchemy/ansisql.py | |
parent | 1f30247e22a4a3a14eb7f57261e289cc26e61bf3 (diff) | |
download | sqlalchemy-6cdba110a49b701e36f93d82e8772d1909385175.tar.gz |
factored "sequence" execution in postgres in oracle to be generalized to the SQLEngine, to also allow space for "defaults" that may be constants, python functions, or SQL functions/statements
Sequence schema object extends from a more generic "Default" object
ANSICompiled can convert positinal params back to a dictionary, but the whole issue of parameters and how the engine executes compiled objects with parameters should be revisited
mysql has fixes for its "rowid_column" being hidden else it screws up some query construction, also will not use AUTOINCREMENT unless the column is Integer
Diffstat (limited to 'lib/sqlalchemy/ansisql.py')
-rw-r--r-- | lib/sqlalchemy/ansisql.py | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/sqlalchemy/ansisql.py b/lib/sqlalchemy/ansisql.py index 658c6f4c1..cd1d3a0b0 100644 --- a/lib/sqlalchemy/ansisql.py +++ b/lib/sqlalchemy/ansisql.py @@ -104,14 +104,26 @@ class ANSICompiler(sql.Compiled): return self.wheres.get(obj, None) def get_params(self, **params): - """returns the bind params for this compiled object, with values overridden by - those given in the **params dictionary""" + """returns a structure of bind parameters for this compiled object. + This includes bind parameters that might be compiled in via the "values" + argument of an Insert or Update statement object, and also the given **params. + The keys inside of **params can be any key that matches the BindParameterClause + objects compiled within this object. The output is dependent on the paramstyle + of the DBAPI being used; if a named style, the return result will be a dictionary + with keynames matching the compiled statement. If a positional style, the output + will be a list corresponding to the bind positions in the compiled statement. + + for an executemany style of call, this method should be called for each element + in the list of parameter groups that will ultimately be executed. + """ d = {} if self.bindparams is not None: bindparams = self.bindparams.copy() else: bindparams = {} bindparams.update(params) + # TODO: cant we make "d" an ordereddict and add params in + # positional order for key, value in bindparams.iteritems(): try: b = self.binds[key] @@ -127,6 +139,20 @@ class ANSICompiler(sql.Compiled): else: return d + def get_named_params(self, parameters): + """given the results of the get_params method, returns the parameters + in dictionary format. For a named paramstyle, this just returns the + same dictionary. For a positional paramstyle, the given parameters are + assumed to be in list format and are converted back to a dictionary. + """ + if self.positional: + p = {} + for i in range(0, len(self.positiontup)): + p[self.positiontup[i]] = parameters[i] + return p + else: + return parameters + def visit_column(self, column): if len(self.select_stack): # if we are within a visit to a Select, set up the "typemap" @@ -390,3 +416,5 @@ class ANSISchemaDropper(sqlalchemy.engine.SchemaIterator): self.execute() +class ANSIDefaultRunner(sqlalchemy.engine.DefaultRunner): + pass
\ No newline at end of file |