The annotation stuff works well on the client but I don't think the
problem with the driver can be worked around so easily .. I will look
at the TDS/ODBC traces but I am pretty sure that the type information
is not being sent back from the dataserver to the driver so the driver
does not know how to describe the placeholder. It occurs to me that
the same thing should hold true for anything which is *not* in the
select list .. I can check this out later.

anyway, thanks for your help. My work on the driver has increased my
respect and admiration for the SA design and code.

pjjH


class object_name(sql_functions.GenericFunction):
    __return_type__ = sqltypes.String
    def __init__(self, object_id, database_id=None, **kwargs):
        super(index_col, self).__init__(self, args=(object_id,
database_id), **kwargs)

    functions.update (
        {
            sql_functions.current_timestamp        : 'GETDATE()',
            sql_functions.current_date             : 'GETDATE()',
            sql_functions.session_user             : 'SUSER_NAME()',
            'current_database'                     : 'DB_NAME()',
            'current_user'                         : 'USER_NAME()',
            'object_id'                            : lambda x:
"OBJECT_ID(%s)" % x,
            'length'                               : lambda x: "LEN
(%s)" % x,
            index_col                              : 'index_col%(expr)
s',
            object_name                            : 'OBJECT_NAME%
(expr)s',
            column_name                            : 'col_name%(expr)
s',
            sql_functions.char_length              : lambda x: "LEN
(%s)" % x,
        }
    )


On Mar 3, 5:46 pm, Rick Morrison <rickmorri...@gmail.com> wrote:
> On Tue, Mar 3, 2009 at 5:31 PM, phrrn...@googlemail.com <
>
> phrrn...@googlemail.com> wrote:
>
> > Thanks. I wrapped it as ' (<original_sql>) as foo' as Sybase needs a
> > name for the derived table.You have helped to get primary key and
> > index introspection working on Sybase!
>
> Huh, I thought you were using mssql, as the odbc error in your posted
> traceback seems to indicate a SQL Server ODBC driver. I'm surprised that
> even the system tables in Sybase and Mssql have identical names as well,
> although knowing a bit about mssql's history, I guess I shouldn't be.
>
>
>
> > One interesting and useful bit of information is that one can't use
> > placeholders in the WHERE clause for anything other than column
> > values: Pyodbc over FreeTDS barfs with an unknown type error as it
> > does not know the datatype of functions.
>
> I think there's a way to annotate database functions in SQLA with a return
> type, although I can't remember the syntax right now, or if it would work
> with pyodbc. Might be worth of bit of investigation, though.
--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to