Michael Bayer wrote:
> ideally you should be able to say:
> 
>     func.diary(iddip, fromd, tod, True).select(<params>)
> 
> however this will produce "SELECT diary(?, ?, ?, ?)" which isnt going to 
> work since its naming the function as a column.  Function objects in SA 
> currently are designed to follow the syntax of a column, not a from 
> clause.  this is related to ticket 172 
> http://www.sqlalchemy.org/trac/ticket/172

I see.

> For what you want to do below, i just committed a slight change in 
> changeset 1612 to enable a textual "FROM" clause to check for bind 
> parameter names, so with that revision you can say:
> 
> results = select(['iddip', 'day', 'amount'],
>                  from_obj=[
>   "diary(:iddip,:fromdate,:todate,:live)"],
>                  engine=metadata.engine
>   ).execute(iddip=iddip, fromdate=fromd, todate=tod, live=True)
> 
> theres some more options using the text() function which can also allow 
> you to get typing information in there for the bind parameters as well 
> as the result set but it starts to get a little messy.


Thank you, this does the expected job. But I still miss the proper way 
of joining the above with other tables.

Given also a Table object for example say::

   diary = select(['iddip', 'day', 'amount'],
                  from_obj=[
     "diary(:iddip,:fromdate,:todate,:live)"],
                  engine=metadata.engine)

   persons = Table('person', metadata,
     Column('id', Integer, primary_key=True),
     Column('name', String(40)))

I tried several approaches, like

   qry = diary.join(persons, diary, diary.c.iddip==persons.c.id)

or

   qry = diary.join(persons, diary.c.iddip==persons.c.id)

but these did not work, also swapping the order of selectables.

Wouldn't something like

   diary = FunctTable('diary(:iddip,:fromdate,:todate,:live)', ...)

be a viable solution to the problem as well as a nicer approach to 
ticket #172, if at all possible?

thank you,
ciao, lele.



_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to