From 536eeb212cfa0e48c2eb8895334f40371908a1c5 Mon Sep 17 00:00:00 2001 From: Konsta Vesterinen Date: Fri, 15 Nov 2013 11:14:36 +0200 Subject: [PATCH] Added warning to docs --- sqlalchemy_utils/eav.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sqlalchemy_utils/eav.py b/sqlalchemy_utils/eav.py index 9eea6d4..13def17 100644 --- a/sqlalchemy_utils/eav.py +++ b/sqlalchemy_utils/eav.py @@ -1,4 +1,10 @@ """ +.. warning:: + + This module is *EXPERIMENTAL*. Everything in the API may change in the + future and break backwards compatibility. Use at your own risk. + + SQLAlchemy-Utils provides some helpers for defining EAV_ models. @@ -176,6 +182,7 @@ def instrument_meta_values(mapper, class_): if isinstance(attr_value, MetaValue): attr = attr_value.attr type_column = attr_value.type_column + value_key = key parent_class = getattr(class_, attr).mapper.class_ type_prop = getattr(parent_class, type_column).property @@ -196,15 +203,18 @@ def instrument_meta_values(mapper, class_): ) def setter(self, value): - setattr( - self, - key + '_' + + typed_key = ( + value_key + '_' + type_.type_key( getattr( getattr(self, attr), type_column ) - ), + ) + ) + setattr( + self, + typed_key, value )