Better control on which columns are mapped as properties

Issue #696 resolved
Former user created an issue

(original reporter: ged) We'd like a way to map only a subset of a selectable columns into mapper properties.

Suggested API/syntaxes for this were:

  • explicit_columns=True
  • map_all_columns=False
  • include_props=.. and exclude props=.. ?

See this thread:

http://groups.google.com/group/sqlalchemy/browse_frm/thread/80e35e5ce61ffc3d

Comments (6)

  1. Mike Bayer repo owner

    seems like include_props/exclude_props were what we decided. the loop for adding in columns is at mapper.py line 572 currently - a couple of lines there are all that's needed.

  2. Mike Bayer repo owner
    • changed status to open
    • removed status

    inherits case should be fine, inheriting mappers require python class inheritance be in place.

    two little niggles:

    • the feature will not work properly if "column_prefix" is specified to the mapper (a column_prefix such as "_" indicates that the mapped property names should be prefixed). the include/exclude should be against column.key, not the prefixed key. one of the mappers in the unit test should have a "column_prefix" setting to test.
    • the unit test has a lot of m.compile() happening there, you can just call compile() on one mapper which always compiles everything, or just "compile_mappers()".
  3. Log in to comment