Json 抽出に TypeDecorator を使用していますが、別のモデルがそれを列の 1 つに使用しています。この TypeDecorator を使用して Python リスト オブジェクトを格納しています。
def process_bind_param(self, value, dialect):
# etc...
def process_result_value(self, value, dialect):
# THIS NEVER GETS CALLED!!
if value is not None:
return json.loads(value)
return value
デコレータを使用するモデルにデータを格納すると、 bind_param が適切に呼び出されます。ここで、次のように TypeDecorator を使用してモデルからスキーマを抽出します。
table = Table(table_name, meta, autoload=True, autoload_with=sengine)
次に、クエリ テストを行います (ループして抽出する方法は多数あります)。
for record in source.query(table).all():
print type(record.column_using_custom_type_list_object) == str
# returns true ... this should be false ... should be of type list
# json.loads() returns type list ???
print record.column_using_custom_type_list_object[some_index]
# naturally this prints a character in the string, not a cell
問題は、テーブルがクエリされ、オブジェクトが取得されてから列がフェッチされるときに、process_result_value() が呼び出されないことです。SQLAlchemy リフレクションが依存関係を処理すると思いますか? カスタム型デコレーターを必要とするメタデータを転送するためのコンストラクターのオプションがいくつかありませんか?