TraitText value restricted to max length 255
Trait_text has a sqlalchemy model definition with value column as Text type, but the migrate scripts defined the column type as String(255) leading to Sqlalchemy exception when indexing trait with large text. This fixes the TraitText model value as String(255) to match the migrate script definition and crops the text input to 255 characters. Change-Id: I55eee4e9fcdee8d05f3598a9bc0368bc92a9b238 Closes-Bug: 1447647
This commit is contained in:
parent
027a236ae8
commit
35e574085d
@ -121,6 +121,7 @@ class Trait(base.Model):
|
|||||||
return float(value)
|
return float(value)
|
||||||
if trait_type is cls.DATETIME_TYPE:
|
if trait_type is cls.DATETIME_TYPE:
|
||||||
return timeutils.normalize_time(timeutils.parse_isotime(value))
|
return timeutils.normalize_time(timeutils.parse_isotime(value))
|
||||||
|
# Cropping the text value to match the TraitText value size
|
||||||
if isinstance(value, six.binary_type):
|
if isinstance(value, six.binary_type):
|
||||||
return value.decode('utf-8')
|
return value.decode('utf-8')[:255]
|
||||||
return six.text_type(value)
|
return six.text_type(value)[:255]
|
||||||
|
@ -344,7 +344,7 @@ class TraitText(Base):
|
|||||||
)
|
)
|
||||||
event_id = Column(Integer, ForeignKey('event.id'), primary_key=True)
|
event_id = Column(Integer, ForeignKey('event.id'), primary_key=True)
|
||||||
key = Column(String(255), primary_key=True)
|
key = Column(String(255), primary_key=True)
|
||||||
value = Column(Text)
|
value = Column(String(255))
|
||||||
|
|
||||||
|
|
||||||
class TraitInt(Base):
|
class TraitInt(Base):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user