On Fri, Jan 15, 2010 at 18:11, [email protected] <[email protected]> wrote:

> I would like to be able to map an Entity against an arbitrary select,
> as can be done in plain sqlalchemy :
>
> http://www.sqlalchemy.org/docs/05/mappers.html#mapping-a-class-against-arbitrary-selects
>
> It is my understanding that this is currently not possible with
> Elixir,

Indeed.

> and cumbersome to setup in sqlalchemy when using Elixir ??

Not really, but (as of now) you can't get a relationship from the
Elixir mapped entities to the plain SQLAlchemy ones (the opposite is
possible but slightly tricky).

> Looking at the Elixir code, I seems possible to create an
> additional argument to using options to specify the select

Yes, that's true.

>, which would result in code like :
>
> class Customer(Entity):
>    using_options(select=lambda:Organization.table.join
> (Purchases.table))

I don't think requiring a function (instead of a plain table object)
is a good idea here, but it can be useful in some cases (like in your
example) so it would be best if it supported both a straight
selectable or a callable. Also, I would name the argument either
"selectable" or simply "table".

> and then process this argument in EntityDescriptor.setup_mapper

AFAIK, you wouldn't need to change anything in setup_mapper. You would
probably need to change stuff in setup_table and possibly other
places.

> Would that be a good move ?
> Would it be likely that such a patch gets accepted ?

As long as it works, doesn't break anything and is not too ugly code,
yes, sure. And it would be very appreciated too since I have wanted to
support this for a long long time (but never got to it since I never
actually needed that).

-- 
Gaëtan de Menten
http://openhex.org
-- 
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en.


Reply via email to