Skip to content

Commit 57a951f

Browse files
committed
Switch from char field to text field types
1 parent 1b26cd4 commit 57a951f

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

chatterbot/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
The number 255 is used because that is the maximum length of a char field
99
in most databases. This value should be enforced on a per-model basis by
1010
the data model for each storage adapter.
11+
12+
DEPRECATED: This value is no longer as of ChatterBot 1.2.7. Statement tables
13+
are now created with a text field.
1114
'''
1215
STATEMENT_TEXT_MAX_LENGTH = 255
1316

chatterbot/ext/django_chatterbot/abstract_models.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ class AbstractBaseStatement(models.Model, StatementMixin):
4949
using the attributes that exist on the default models.
5050
"""
5151

52-
text = models.CharField(
53-
max_length=constants.STATEMENT_TEXT_MAX_LENGTH,
52+
text = models.TextField(
5453
help_text='The text of the statement.'
5554
)
5655

57-
search_text = models.CharField(
58-
max_length=constants.STATEMENT_TEXT_MAX_LENGTH,
56+
search_text = models.TextField(
5957
blank=True,
6058
help_text='A modified version of the statement text optimized for searching.'
6159
)
@@ -70,14 +68,12 @@ class AbstractBaseStatement(models.Model, StatementMixin):
7068
help_text='The date and time that the statement was created at.'
7169
)
7270

73-
in_response_to = models.CharField(
74-
max_length=constants.STATEMENT_TEXT_MAX_LENGTH,
71+
in_response_to = models.TextField(
7572
null=True,
7673
help_text='The text of the statement that this statement is in response to.'
7774
)
7875

79-
search_in_response_to = models.CharField(
80-
max_length=constants.STATEMENT_TEXT_MAX_LENGTH,
76+
search_in_response_to = models.TextField(
8177
blank=True,
8278
help_text='A modified version of the in_response_to text optimized for searching.'
8379
)

chatterbot/ext/sqlalchemy_app/models.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from sqlalchemy import Table, Column, Integer, String, DateTime, ForeignKey
1+
from sqlalchemy import Table, Column, Integer, String, Text, DateTime, ForeignKey
22
from sqlalchemy.orm import relationship, declarative_base
33
from sqlalchemy.sql import func
44
from sqlalchemy.ext.declarative import declared_attr
@@ -55,12 +55,10 @@ class Statement(Base, StatementMixin):
5555

5656
confidence = 0
5757

58-
text = Column(
59-
String(constants.STATEMENT_TEXT_MAX_LENGTH)
60-
)
58+
text = Column(Text)
6159

6260
search_text = Column(
63-
String(constants.STATEMENT_TEXT_MAX_LENGTH),
61+
Text,
6462
nullable=False,
6563
server_default=''
6664
)
@@ -83,12 +81,12 @@ class Statement(Base, StatementMixin):
8381
)
8482

8583
in_response_to = Column(
86-
String(constants.STATEMENT_TEXT_MAX_LENGTH),
84+
Text,
8785
nullable=True
8886
)
8987

9088
search_in_response_to = Column(
91-
String(constants.STATEMENT_TEXT_MAX_LENGTH),
89+
Text,
9290
nullable=False,
9391
server_default=''
9492
)

0 commit comments

Comments
 (0)