On Jul 3, 5:26 am, klaus <[EMAIL PROTECTED]> wrote:
> Yes, of course. ;-) But is it possible not to map certain columns?
> Preferably, without using a select and listing every single column
> that should be present?
well not including those columns in the selectable is the easiest way
to do this. it would be a mess to offer both "inclusive" and
"exclusive" APIs for indicating which columns you want. mapping to a
select among three tables is a pretty uncommon use case.
>
> Foreign key columns are obvious candidates to be left out, because the
> relations should be used instead. Currently, I always rename them into
> private attributes (with a leading underscore).
the join() object has the ability to "flatten" its columns list like
this, using the method myjoin.select(fold_equivalents=true). but
also, you can "flatten" the columns at the attribute level, described
in the docs on the site.
>
> BTW, the mapper might want to check that keys are nonempty strings and
> no two columns are mapped to the same attribute (currently, the last
> one wins).
multiple columns mapped to a single attribute is a common case, as
above where two attributes share the same value via foreign key
relationship. this case is featured in the main documentation on
mapping to selects. primary keys columns starting out as empty is
usually the rule and not the exception when an INSERT is performed
since column defaults or sequences usually provide the new primary key
values.
>
> Best regards
> Klaus
>
> On 2 Jul., 18:12, Michael Bayer <[EMAIL PROTECTED]> wrote:
>
> > On Jul 2, 2007, at 10:40 AM, klaus wrote:
>
> > > I would rather ask: How can this behavior be avoided? Is it possible
> > > to mark some columns as read-only/no-write-back?
>
> > just remove the primary key columns of the "non-write" tables from
> > the columns clause of the select.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---