mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-21 18:55:16 +02:00
fix: update Google Drive indexer to use SQLAlchemy casting for metadata queries
- Modified the Google Drive indexer to use SQLAlchemy's cast function for querying document metadata, ensuring proper type handling for file IDs. - Improved the consistency of metadata queries across the indexing functions, enhancing reliability in document retrieval and processing.
This commit is contained in:
parent
5cf6fb15ed
commit
97d7207bd4
1 changed files with 4 additions and 4 deletions
|
|
@ -578,7 +578,7 @@ async def _check_rename_only_update(
|
||||||
- (True, message): Only filename changed, document was updated
|
- (True, message): Only filename changed, document was updated
|
||||||
- (False, None): Content changed or new file, needs full processing
|
- (False, None): Content changed or new file, needs full processing
|
||||||
"""
|
"""
|
||||||
from sqlalchemy import select
|
from sqlalchemy import cast, select, String
|
||||||
from sqlalchemy.orm.attributes import flag_modified
|
from sqlalchemy.orm.attributes import flag_modified
|
||||||
|
|
||||||
from app.db import Document
|
from app.db import Document
|
||||||
|
|
@ -603,7 +603,7 @@ async def _check_rename_only_update(
|
||||||
select(Document).where(
|
select(Document).where(
|
||||||
Document.search_space_id == search_space_id,
|
Document.search_space_id == search_space_id,
|
||||||
Document.document_type == DocumentType.GOOGLE_DRIVE_FILE,
|
Document.document_type == DocumentType.GOOGLE_DRIVE_FILE,
|
||||||
Document.document_metadata["google_drive_file_id"].astext == file_id,
|
cast(Document.document_metadata["google_drive_file_id"], String) == file_id,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
existing_document = result.scalar_one_or_none()
|
existing_document = result.scalar_one_or_none()
|
||||||
|
|
@ -755,7 +755,7 @@ async def _remove_document(session: AsyncSession, file_id: str, search_space_id:
|
||||||
|
|
||||||
Handles both new (file_id-based) and legacy (filename-based) hash schemes.
|
Handles both new (file_id-based) and legacy (filename-based) hash schemes.
|
||||||
"""
|
"""
|
||||||
from sqlalchemy import select
|
from sqlalchemy import cast, select, String
|
||||||
|
|
||||||
from app.db import Document
|
from app.db import Document
|
||||||
|
|
||||||
|
|
@ -774,7 +774,7 @@ async def _remove_document(session: AsyncSession, file_id: str, search_space_id:
|
||||||
select(Document).where(
|
select(Document).where(
|
||||||
Document.search_space_id == search_space_id,
|
Document.search_space_id == search_space_id,
|
||||||
Document.document_type == DocumentType.GOOGLE_DRIVE_FILE,
|
Document.document_type == DocumentType.GOOGLE_DRIVE_FILE,
|
||||||
Document.document_metadata["google_drive_file_id"].astext == file_id,
|
cast(Document.document_metadata["google_drive_file_id"], String) == file_id,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
existing_document = result.scalar_one_or_none()
|
existing_document = result.scalar_one_or_none()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue