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/databases/mysql.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/databases/mysql.py')
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index 1eef6facb..191a57ba6 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -140,10 +140,10 @@ class MySQLEngine(ansisql.ANSISQLEngine): def last_inserted_ids(self): return self.context.last_inserted_ids - def post_exec(self, connection, cursor, statement, parameters, echo = None, compiled = None, **kwargs): + def post_exec(self, proxy, statement, parameters, compiled = None, **kwargs): if compiled is None: return if getattr(compiled, "isinsert", False): - self.context.last_inserted_ids = [cursor.lastrowid] + self.context.last_inserted_ids = [proxy().lastrowid] # executemany just runs normally, since we arent using rowcount at all with mysql # def _executemany(self, c, statement, parameters): @@ -168,9 +168,12 @@ class MySQLTableImpl(sql.TableImpl): def _rowid_col(self): if getattr(self, '_mysql_rowid_column', None) is None: if len(self.table.primary_key) > 0: - self._mysql_rowid_column = self.table.primary_key[0] + c = self.table.primary_key[0] else: - self._mysql_rowid_column = self.table.columns[self.table.columns.keys()[0]] + c = self.table.columns[self.table.columns.keys()[0]] + self._mysql_rowid_column = schema.Column(c.name, c.type, hidden=True) + self._mysql_rowid_column._set_parent(self.table) + return self._mysql_rowid_column rowid_column = property(lambda s: s._rowid_col()) @@ -195,7 +198,7 @@ class MySQLSchemaGenerator(ansisql.ANSISchemaGenerator): if column.primary_key: if not override_pk: colspec += " PRIMARY KEY" - if first_pk: + if first_pk and isinstance(column.type, types.Integer): colspec += " AUTO_INCREMENT" if column.foreign_key: colspec += " REFERENCES %s(%s)" % (column.column.foreign_key.column.table.name, column.column.foreign_key.column.name) |