Autoloading only certain columns

Issue #561 resolved
Former user created an issue

A Table option to autoload only certain columns would be useful. This would allow selects, updates, and mapper classes to avoid loading large or numerous fields that the caller will never access. It can be implemented as a constructor arg listing the desired column names:

my_table = Table("Foo", meta, autoload_columns=["first_name", "last_name"]("meta_id",))

This proposal is simpler and more straightforward than the alternatives:

  • Not autoloading. That requires one to hardcode the column types, which is bad if the table is admin'd externally.
  • Calling .noload() on mapped objects. It's better to list desired columns rather than undesired ones, especially since you may not know all the undesired columns that exist now or may be added in the future.
  • Table.select() can't choose a subset of columns, forcing one to use the less convenient select() function instead.
  • SQL queries have .append_column() but no corresponding .remove_column().

Comments (4)

  1. Log in to comment