Thanks Runar, this should come in handy. I'll check back in with you as I work throught this.

I presume that since you added the FROM clause massaging to the SQLCompiler class that this problem runs throughout "normal" queries too. Ugg.

Rick


On 2/16/06, Runar Petursson <[EMAIL PROTECTED]> wrote:
Here is my patch for mssql.  It works for me on both Unix (using
pymssql) and Windows (using ADODBAPI.  There are still some things to
work out regarding the ADODBAPI transactions/rollback.  There are
several work-arounds, including the From clause issue and Identity
column issues.

The other thing it does is modify one line in information_schema as follows:

Index: lib/sqlalchemy/databases/information_schema.py
===================================================================
--- lib/sqlalchemy/databases/information_schema.py      (revision 902)
+++ lib/sqlalchemy/databases/information_schema.py      (working copy)
@@ -112,7 +112,7 @@
#        print "row! " + repr(row)
  #       continue
         (name, type, nullable, charlen, numericprec, numericscale) = (
-            row[columns.c.column_name],
+            row[columns.c.column_name].encode('iso-8859-1', 'replace'),
             row[columns.c.data_type],
             row[columns.c.is_nullable] == 'YES',
             row[columns.c.character_maximum_length],

Which otherwise caused problems when the column_name came back as
Unicode and was then used as a keyword argument in a method--which
then died.  Perhaps there is a cleaner solution.

On 2/16/06, Runar Petursson <[EMAIL PROTECTED]> wrote:
> Hey Rick,
>
> I have written some this.  It doesn't pass all of the tests yet, but
> It works pretty well for starters.  I'll send in a few minutes to the
> list.
>
> On 2/16/06, Rick Morrision < [EMAIL PROTECTED]> wrote:
> > Hi everybody:
> >
> >  I've begun work on a database engine for MS-SQL (if anyone else is working
> > on this, please let me know ASAP).
> >
> >  One of the issues I've run into is that attempting to do table reflection
> > generates an internal query for which MSSQL seems to require a table alias.
> >
> >  The query, from information_schema.py is:
> >
> >      s = select([columns],
> >          sql.and_(columns.c.table_name==table.name,
> > columns.c.table_schema==current_schema)
> >          order_by=[columns.c.ordinal_position ])
> >
> >  which for a table named 'SysParms', would generate the following query:
> >
> >  SELECT columns.table_schema, columns.table_name, columns.column_name,
> > columns.is_nullable , columns.data_type, columns.ordinal_position,
> > columns.character_maximum_length,
> > columns.numeric_precision, columns.numeric_scale, columns.column_default
> >  FROM information_schema.columns
> >  WHERE columns.table_name = 'SysParms' AND columns.table_schema = 'dbo'
> > ORDER BY columns.ordinal_position
> >
> >  which then fails with a string of:
> >
> >  Server: Msg 107, Level 16, State 2, Line 1
> >  The column prefix 'columns' does not match with a table name or alias name
> > used in the query.
> >
> >  Changing the FROM clause in the query to:
> >
> >  FROM information_schema.columns AS columns
> >
> >  Fixes things.
> >
> >  Now, how do I force the query generator to use a table alias? I've tried
> > using:
> >
> >   columns = columns.alias('columns')
> >
> >  Which then fails with a "no for clause" error
> >
> >  Help?
> >
> >  Thanks,
> >  Rick
--
Runar Petursson
Betur
[EMAIL PROTECTED] -- http://betur.net



Reply via email to