Skip to content

fix: preserve extensionless document suffix on GaussDB - #18483

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
lilee-LI:fix/gaussdb-extensionless-document
Aug 19, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
lilee-LI:fix/gaussdb-extensionless-document

Conversation

@Sevenzuo

Copy link
Copy Markdown
Contributor

Summary

RAGFlow's "Create empty document" flow accepts names without a file extension. The POST /datasets/<dataset_id>/documents?type=empty route calls _upload_empty_document(), where Path(name).suffix.lstrip(".") returns "".

In GaussDB's A/ORA compatibility mode, that empty string is persisted as SQL NULL. Because document.suffix was defined as NOT NULL, the insert failed with a constraint violation.

Reproduction

GaussDB extensionless empty document creation failure

Changes

  • Use the existing EmptyStringCharField for Document.suffix.
  • Apply the same field type in the historical add-column migration.
  • Relax document.suffix to nullable for existing GaussDB metadata schemas.
  • Add regression coverage for field conversion, migration ordering, and non-GaussDB behavior.

Compatibility

Only GaussDB maps the application-level empty string to SQL NULL and restores it to "" on reads. MySQL, PostgreSQL, and OceanBase retain the original NOT NULL constraint and continue storing "" unchanged.

Tests

  • python -m pytest test/unit_test/api/db/test_gaussdb_adaptation_points.py test/unit_test/api/db/test_gaussdb_user_flow.py::test_gaussdb_empty_string_compatible_fields_are_nullable_only_for_gaussdb -q — 18 passed
  • lefthook run pre-commit — all checks passed

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🌈 python Pull requests that update Python code 🐞 bug Something isn't working, pull request that fix bug. 🧪 test Pull requests that update test cases. labels Aug 19, 2026
@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 533e5d2b-5b59-4671-80e9-bfa8b79346cd

📥 Commits

Reviewing files that changed from the base of the PR and between 808f216 and 7cad270.

📒 Files selected for processing (3)
  • api/db/db_models.py
  • test/unit_test/api/db/test_gaussdb_adaptation_points.py
  • test/unit_test/api/db/test_gaussdb_user_flow.py

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Document.suffix now uses EmptyStringCharField. GaussDB compatibility mapping and migrations support the field. Tests cover GaussDB, MySQL, PostgreSQL, and OceanBase behavior.

Changes

Document suffix compatibility

Layer / File(s) Summary
Suffix field and migration compatibility
api/db/db_models.py
Document.suffix uses EmptyStringCharField, is included in the GaussDB compatibility mapping, and uses the compatible field in migrations.
Backend behavior validation
test/unit_test/api/db/test_gaussdb_adaptation_points.py, test/unit_test/api/db/test_gaussdb_user_flow.py
Tests verify GaussDB nullability relaxation and confirm that other backends retain non-null constraints while preserving empty strings.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 7cad2

The PR applies a localized compatibility fix for extensionless documents and adds regression coverage; no actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

Suggested reviewers: zws202606

Poem

A rabbit checks the suffix field,
GaussDB makes empty strings yield.
MySQL keeps the value bright,
Tests guard each backend right.
Hop, hop—migration paths are sealed!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description explains the problem, changes, compatibility behavior, and test results with sufficient reviewer context.
Title check ✅ Passed The title clearly identifies the GaussDB fix for preserving extensionless document suffixes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JinHai-CN
JinHai-CN requested a review from Lynn-Inf August 19, 2026 04:30

@Lynn-Inf Lynn-Inf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please also update entity.Document.Suffix in Go — this ensures the field is properly adapted in the Go ragflow_server when connecting to GaussDB.

@Sevenzuo

Copy link
Copy Markdown
Contributor Author

@Lynn-Inf Thanks. The Go ragflow_server does not support GaussDB metadata yet. We will adapt entity.Document.Suffix together with the Go GaussDB implementation in a follow-up PR.

@Lynn-Inf Lynn-Inf added the ci Continue Integration label Aug 19, 2026
@Lynn-Inf
Lynn-Inf self-requested a review August 19, 2026 09:34

@Lynn-Inf Lynn-Inf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — merging as soon as CI is green.

@JinHai-CN
JinHai-CN merged commit dd1f335 into infiniflow:main Aug 19, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration 🌈 python Pull requests that update Python code size:XS This PR changes 0-9 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants