On 6 Feb 2006, at 01:25, Michael Bayer wrote:

BANG !!!!! unit test passed on the first try !!  neat-OOO !

Hi Michael,

Just found a new bug as a result of the recent changes to support different engines... I'm using the ProxyEngine class because I'm trying to write a webapp, and it doesn't have the database configuration available at the time it's setting-up its tables. Anyway, this means that the tables are all ProxyTableImpl objects, not MySQLTableImpl objects, so there's no mysql_engine attribute.

For now, I've done the following:

Index: lib/sqlalchemy/ext/proxy.py
===================================================================
--- lib/sqlalchemy/ext/proxy.py (revision 924)
+++ lib/sqlalchemy/ext/proxy.py (working copy)
@@ -66,10 +66,10 @@
         """
         return ProxyColumnImpl(self, column)
-    def tableimpl(self, table):
+    def tableimpl(self, table, **kwargs):
         """Proxy point: return a ProxyTableImpl
         """
-        return ProxyTableImpl(self, table)
+        return ProxyTableImpl(self, table, **kwargs)

     def type_descriptor(self, typeobj):
         """Proxy point: return a ProxyTypeEngine
@@ -96,9 +96,10 @@
class ProxyTableImpl(sql.TableImpl):
     """Proxy table; defers engine access to ProxyEngine
     """
-    def __init__(self, engine, table):
+    def __init__(self, engine, table, **kwargs):
         sql.TableImpl.__init__(self, table)
         self._engine = engine
+        self.__dict__.update(kwargs)
     engine = property(lambda self: self._engine.engine)
Index: lib/sqlalchemy/databases/mysql.py
===================================================================
--- lib/sqlalchemy/databases/mysql.py   (revision 924)
+++ lib/sqlalchemy/databases/mysql.py   (working copy)
@@ -261,7 +261,7 @@
         return colspec
     def post_create_table(self, table):
-        if table.mysql_engine is not None:
+ if hasattr(table, 'mysql_engine') and table.mysql_engine is not None:
             return " ENGINE=%s" % table.mysql_engine
         else:
             return ""


which fixes it although I'm not hugely fond of how it does so. I think this really indicates that there needs to be a generic mechanism for obtaining table parameters so that the proxy doesn't interfere. Perhaps there should be a parameter dictionary instead (on sql.TableImpl) and the MySQLTableImpl should read that instead?

Kind regards,

Alastair.

--
http://www.alastairs-place.net




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to