Hi - I'd attach this as a patch file, but it's just too darned small...

I would _love_ it if we didn't automatically stringify compiled
statements here in base.py, because there is no way to override this
behavior in a dialect. I'm working on an NDBAPI dialect to support
direct access to MySQL Cluster storage, and so I never actually have a
string representation of the query. Most of the time this is fine, but
to make it work, I had to have pre_exec do the actual execution,
because by the time I got to do_execute, I didn't have my real object
anymore.

I know this would require some other code changes to actually get
applied - namely, I'm sure there are other places now where the
statement should be str()'d to make sense.

Alternately, we could add a method to Compiled. (I know there is
already get_str()) like "get_final_query()" that gets called in this
context instead. Or even, although it makes my personal code less
readable, just call compiled.get_str() here, which is the least
invasive, but requires non-string queries to override a method called
get_str() to achieve a purpose that is not a stringification.

Other than this, so far I've actually got the darned thing inserting
records, so it's going pretty well... other than a whole bunch of test
code I put in to find out why it wasn't inserting when the problem was
that I was checking the wrong table... *doh*

Thanks!
Monty

=== modified file 'lib/sqlalchemy/engine/base.py'
--- lib/sqlalchemy/engine/base.py       2007-02-13 22:53:05 +0000
+++ lib/sqlalchemy/engine/base.py       2007-03-14 23:17:40 +0000
@@ -312,7 +312,7 @@
            return cursor
        context = self.__engine.dialect.create_execution_context()
        context.pre_exec(self.__engine, proxy, compiled, parameters)
-        proxy(str(compiled), parameters)
+        proxy(compiled, parameters)
        context.post_exec(self.__engine, proxy, compiled, parameters)
        rpargs = self.__engine.dialect.create_result_proxy_args(self, cursor)
        return ResultProxy(self.__engine, self, cursor, context,
typemap=compiled.typemap, columns=compiled.columns, **rpargs)
@@ -342,7 +342,7 @@
        if cursor is None:
            cursor = self.__engine.dialect.create_cursor(self.connection)
        try:
-            self.__engine.logger.info(statement)
+            self.__engine.logger.info(str(statement))
            self.__engine.logger.info(repr(parameters))
            if parameters is not None and isinstance(parameters, list)
and len(parameters) > 0 and (isinstance(parameters[0], list) or
isinstance(parameters[0], dict)):
                self._executemany(cursor, statement, parameters,
context=context)

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to