From 324644422b43bfa937736bc93987302c1b5f691c Mon Sep 17 00:00:00 2001 From: Gunther Cox Date: Sun, 16 Jul 2017 15:56:27 -0400 Subject: [PATCH] Fix setup of primary keys is sql adapter --- chatterbot/storage/sql_storage.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/chatterbot/storage/sql_storage.py b/chatterbot/storage/sql_storage.py index 7911b14f3..fc6747a9b 100644 --- a/chatterbot/storage/sql_storage.py +++ b/chatterbot/storage/sql_storage.py @@ -32,8 +32,8 @@ def get_statement_serialized(context): del params['text_search'] return json.dumps(params) - id = Column(Integer) - text = Column(String, primary_key=True) + id = Column(Integer, primary_key=True, autoincrement=True) + text = Column(String, unique=True) extra_data = Column(PickleType) in_response_to = relationship( @@ -42,7 +42,6 @@ def get_statement_serialized(context): ) text_search = Column( String, - primary_key=True, default=get_statement_serialized ) @@ -61,8 +60,8 @@ def get_reponse_serialized(context): del params['text_search'] return json.dumps(params) - id = Column(Integer) - text = Column(String, primary_key=True) + id = Column(Integer, primary_key=True, autoincrement=True) + text = Column(String) occurrence = Column(Integer, default=1) statement_text = Column(String, ForeignKey('StatementTable.text')) @@ -74,7 +73,6 @@ def get_reponse_serialized(context): ) text_search = Column( String, - primary_key=True, default=get_reponse_serialized ) @@ -289,6 +287,7 @@ def update(self, statement): # Create the record _response = ResponseTable( text=response.text, + statement_text=statement.text, occurrence=response.occurrence )