[Sqlalchemy-tickets] Issue #3503: add full control for return type under PG ARRAY, HSTORE, JSON, J
Brought to you by:
zzzeek
|
From: Mike B. <iss...@bi...> - 2015-07-29 21:19:44
|
New issue 3503: add full control for return type under PG ARRAY, HSTORE, JSON, JSONB indexed (element) access https://bitbucket.org/zzzeek/sqlalchemy/issues/3503/add-full-control-for-return-type-under-pg Mike Bayer: e.g., if I want myhstorecol['somecol'] to have a custom type, how do I do that? Some system that works for all of these types that defines the return types for indexed access should be devised. 1.1 because this is like a big deal, it's going to come up a lot, but no concrete plan right now. Perhaps a "schema" dictionary. "*" is a wildcard: ``` #!python HSTORE(schema={'*': String}) JSON(schema={'subdict': JSON(schema={'elements': ARRAY(Integer)}}) HSTORE(schema={'foob': String, 'bar': MyMagicType}) ``` dictionary too coarse-grained? Supply a callable instead: ``` #!python HSTORE(schema=lambda key: String if key =="foo" else MyMagicType) ``` |