haystack-core-integrations
haystack-core-integrations copied to clipboard
PgvectorDocumentStore: DB not initialized in delete_table method
Describe the bug
The delete_table() and delete_table_async() methods do not call _ensure_db_setup() first. Thus, if delete_table() is the first call on the document store, it will fail.
To Reproduce
- Create a PgvectorDocumentStore instance.
- Call
delete_table()on the instance.
app-sg-1 | File "/app/core/admin.py", line 90, in save_model
app-sg-1 | store.delete_table()
app-sg-1 | ~~~~~~~~~~~~~~~~~~^^
app-sg-1 | File "/py/lib/python3.13/site-packages/haystack_integrations/document_stores/pgvector/document_store.py", line 500, in delete_table
app-sg-1 | self._execute_sql(
app-sg-1 | ~~~~~~~~~~~~~~~~~^
app-sg-1 | delete_sql,
app-sg-1 | ^^^^^^^^^^^
app-sg-1 | error_msg=f"Could not delete table {self.schema_name}.{self.table_name} in PgvectorDocumentStore",
app-sg-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app-sg-1 | )
app-sg-1 | ^
app-sg-1 | File "/py/lib/python3.13/site-packages/haystack_integrations/document_stores/pgvector/document_store.py", line 270, in _execute_sql
app-sg-1 | raise ValueError(message)
app-sg-1 |ValueError: The cursor or the connection is not initialized. Make sure to call _ensure_db_setup() before calling this method.
Describe your environment (please complete the following information):
- OS: MacOS, Linux
- Haystack version: haystack-ai==2.11.2
- Integration version: pgvector-haystack==3.2.0