LightRAG/lightrag
BukeLy 982b63c9be fix: correct AsyncPG parameter passing in PostgreSQL migration to prevent data corruption
Why this change is needed:
The migration code at line 2351 was passing a dictionary (row_dict) as parameters
to a SQL query that used positional placeholders ($1, $2, etc.). AsyncPG strictly
requires positional parameters to be passed as a list/tuple of values in the exact
order matching the placeholders. Using a dictionary would cause parameter mismatches
and migration failures, potentially corrupting migrated data or causing the entire
migration to fail silently.

How it solves it:
- Extract values from row_dict in the exact order defined by the columns list
- Pass values as separate positional arguments using *values unpacking
- Added clear comments explaining AsyncPG's requirements
- Updated comment from "named parameters" to "positional parameters" for accuracy

Impact:
- Migration now correctly maps values to SQL placeholders
- Prevents data corruption during legacy table migration
- Ensures reliable data transfer from old to new table schemas
- All PostgreSQL migration tests pass (6/6)

Testing:
- Verified with `uv run pytest tests/test_postgres_migration.py -v` - all tests pass
- Pre-commit hooks pass (ruff-format, ruff)
- Tested parameter ordering logic matches AsyncPG requirements
2025-11-20 01:59:34 +08:00
..
api Bump API version to 0256 2025-11-18 23:15:31 +08:00
evaluation Update LLM cache migration docs and improve UX prompts 2025-11-08 23:48:19 +08:00
kg fix: correct AsyncPG parameter passing in PostgreSQL migration to prevent data corruption 2025-11-20 01:59:34 +08:00
llm Improve Bedrock error handling with retry logic and custom exceptions 2025-11-17 12:54:32 +08:00
tools Improve LightRAG initialization checker tool with better usage docs 2025-11-17 15:42:54 +08:00
__init__.py Bump core version to 1.4.9.9 and API to 0252 2025-11-08 11:27:26 +08:00
base.py style: fix lint issues (trailing whitespace and formatting) 2025-11-20 01:28:39 +08:00
constants.py Refactor entity merging with unified attribute merge function 2025-10-27 00:04:17 +08:00
exceptions.py Auto-initialize pipeline status in LightRAG.initialize_storages() 2025-11-17 12:54:33 +08:00
lightrag.py style: fix lint issues (trailing whitespace and formatting) 2025-11-20 01:28:39 +08:00
namespace.py Add entity/relation chunk tracking with configurable source ID limits 2025-10-20 15:24:15 +08:00
operate.py Adjust chunking parameters to match the default environment variable settings 2025-11-18 23:14:50 +08:00
prompt.py Fix typo in 'equipment' in prompt.py 2025-10-22 11:13:22 +08:00
rerank.py fix: Resolve default rerank config problem when env var missing 2025-08-23 01:07:59 +08:00
types.py
utils.py style: fix lint issues (trailing whitespace and formatting) 2025-11-20 01:28:39 +08:00
utils_graph.py Improve entity merge logging by removing redundant message and fixing typo 2025-10-31 17:16:59 +08:00