[FIX] fields: inherited fields should get 'string' from their parent field
Because some parameters of a field may be determined during its setup, we have to update the corresponding column after the setup, and recompute _all_columns to make it consistent.
This commit is contained in:
parent
3e07eaa308
commit
8db5b84fc1
|
@ -319,7 +319,8 @@ class Field(object):
|
||||||
self._free_attrs.append(attr)
|
self._free_attrs.append(attr)
|
||||||
setattr(self, attr, value)
|
setattr(self, attr, value)
|
||||||
|
|
||||||
if not self.string:
|
if not self.string and not self.related:
|
||||||
|
# related fields get their string from their parent field
|
||||||
self.string = name.replace('_', ' ').capitalize()
|
self.string = name.replace('_', ' ').capitalize()
|
||||||
|
|
||||||
# determine self.default and cls._defaults in a consistent way
|
# determine self.default and cls._defaults in a consistent way
|
||||||
|
|
|
@ -2980,6 +2980,12 @@ class BaseModel(object):
|
||||||
if not partial:
|
if not partial:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
# update columns (fields may have changed), and column_infos
|
||||||
|
for name, field in self._fields.iteritems():
|
||||||
|
if field.store:
|
||||||
|
self._columns[name] = field.to_column()
|
||||||
|
self._inherits_reload()
|
||||||
|
|
||||||
# group fields by compute to determine field.computed_fields
|
# group fields by compute to determine field.computed_fields
|
||||||
fields_by_compute = defaultdict(list)
|
fields_by_compute = defaultdict(list)
|
||||||
for field in self._fields.itervalues():
|
for field in self._fields.itervalues():
|
||||||
|
|
Loading…
Reference in New Issue