Re: [Sqlalchemy-tickets] [sqlalchemy] #1312: mssql reflection not working
Brought to you by:
zzzeek
From: sqlalchemy <mi...@zz...> - 2009-03-09 22:09:25
|
#1312: mssql reflection not working ----------------------------+----------------------------------------------- Reporter: guest | Owner: ram Type: defect | Status: new Priority: medium | Milestone: 0.5.xx Component: mssql | Severity: no triage selected yet Resolution: | Keywords: reflection Status_field: needs tests | ----------------------------+----------------------------------------------- Comment (by guest): Yes, the str() call on the result from sql.text() improves things and if I change the actual statement with a str() call, then reflection appears to work. Now perhaps this would all be unnecessary if I could set the character set properly in freetds/odbc but what is below works for me. {{{ Index: lib/python2.5/site- packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/databases/mssql.py =================================================================== --- lib/python2.5/site- packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/databases/mssql.py (revision 572) +++ lib/python2.5/site- packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/databases/mssql.py (working copy) @@ -1066,7 +1066,7 @@ @base.connection_memoize(('dialect', 'default_schema_name')) def get_default_schema_name(self, connection): query = "SELECT user_name() as user_name;" - user_name = connection.scalar(sql.text(query)) + user_name = connection.scalar(str(sql.text(query))) if user_name is not None: # now, get the default schema query = """ @@ -1076,7 +1076,7 @@ AND type = 'S' """ try: - default_schema_name = connection.scalar(sql.text(query), + default_schema_name = connection.scalar(str(sql.text(query)), user_name=user_name) if default_schema_name is not None: return default_schema_name @@ -1169,7 +1169,7 @@ coltype = coltype(**kwargs) colargs = [] if default is not None: - colargs.append(schema.DefaultClause(sql.text(default))) + colargs.append(schema.DefaultClause(str(sql.text(default)))) table.append_column(schema.Column(name, coltype, nullable=nullable, autoincrement=False, *colargs)) if not found_table: Index: lib/python2.5/site- packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/engine/base.py =================================================================== --- lib/python2.5/site- packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/engine/base.py (revision 572) +++ lib/python2.5/site- packages/SQLAlchemy-0.5.2-py2.5.egg/sqlalchemy/engine/base.py (working copy) @@ -945,7 +945,7 @@ self.engine.logger.info(statement) self.engine.logger.info(repr(parameters)) try: - self.dialect.do_execute(cursor, statement, parameters, context=context) + self.dialect.do_execute(cursor, str(statement), parameters, context=context) except Exception, e: self._handle_dbapi_exception(e, statement, parameters, cursor, context) raise }}} -- Ticket URL: <http://www.sqlalchemy.org/trac/ticket/1312#comment:15> sqlalchemy <http://www.sqlalchemy.org/> The Database Toolkit for Python |