|
9 | 9 | from haystack.document_stores.errors import DuplicateDocumentError |
10 | 10 | from haystack.document_stores.types import DocumentStore, DuplicatePolicy |
11 | 11 | from haystack.utils.auth import Secret, deserialize_secrets_inplace |
| 12 | +from postgrest import CountMethod |
12 | 13 |
|
13 | 14 | from supabase import Client, create_client |
14 | 15 |
|
@@ -123,7 +124,7 @@ def count_documents(self) -> int: |
123 | 124 | if self._client is None: |
124 | 125 | msg = "Call warm_up() before using the document store." |
125 | 126 | raise RuntimeError(msg) |
126 | | - result = self._client.table(self.table_name).select("*", count="exact").execute() |
| 127 | + result = self._client.table(self.table_name).select("*", count=CountMethod.exact).execute() |
127 | 128 | return int(result.count) if result.count is not None else 0 |
128 | 129 |
|
129 | 130 | def filter_documents(self, filters: dict[str, Any] | None = None) -> list[Document]: |
@@ -170,12 +171,12 @@ def _apply_filters(self, query: Any, filters: dict[str, Any]) -> Any: |
170 | 171 | query = query.eq(f"meta->>'{meta_key}'", value) |
171 | 172 | elif op == "!=": |
172 | 173 | query = query.neq(f"meta->>'{meta_key}'", value) |
173 | | - elif op == "==": |
174 | | - query = query.eq(field, value) |
175 | | - elif op == "!=": |
176 | | - query = query.neq(field, value) |
177 | | - elif op == "in": |
178 | | - query = query.in_(field, value) |
| 174 | + elif op == "==": |
| 175 | + query = query.eq(field, value) |
| 176 | + elif op == "!=": |
| 177 | + query = query.neq(field, value) |
| 178 | + elif op == "in": |
| 179 | + query = query.in_(field, value) |
179 | 180 |
|
180 | 181 | return query |
181 | 182 |
|
@@ -264,7 +265,8 @@ def _groonga_retrieval( |
264 | 265 | {"query_text": query, "table": self.table_name, "top_k": top_k}, |
265 | 266 | ).execute() |
266 | 267 |
|
267 | | - documents = [self._to_haystack_document(row) for row in (result.data or []) if isinstance(row, dict)] |
| 268 | + data = result.data if isinstance(result.data, list) else [] |
| 269 | + documents = [self._to_haystack_document(row) for row in data if isinstance(row, dict)] |
268 | 270 |
|
269 | 271 | # Apply filters post-retrieval if provided |
270 | 272 | if filters: |
|
0 commit comments