Skip to content

fix(dbml): report one-based model line numbers - #160

Merged
FROWNINGdev merged 1 commit into
FROWNINGdev:mainfrom
syedmustafan:fix/dbml-one-based-line-notes
Oct 19, 2026
Merged

FROWNINGdev merged 1 commit into
FROWNINGdev:mainfrom
syedmustafan:fix/dbml-one-based-line-notes

Conversation

@syedmustafan

@syedmustafan syedmustafan commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #139.

DBML model notes exposed ParsedModel.line_number directly even though it is zero-based, producing source locations one line early. Add one when formatting the human-facing note and cover the behavior with fixture-backed tests.

Tests: PYTHONPATH=cli python3 -m unittest cli.tests.test_er_formats (16 passed).

Summary by CodeRabbit

  • Bug Fixes
    • Corrected source line numbers shown in DBML table notes to use one-based numbering.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6d472d7c-9de0-4058-94b4-15bcb18a586a
📥 Commits

Reviewing files that changed from the base of the PR and between 65fe932 and a1dc705.

📒 Files selected for processing: 2
  • cli/django_orm_lens/er_formats.py
  • cli/tests/test_er_formats.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

DBML table notes now report one-based source line numbers. A test checks the notes for models on lines 4 and 13.

Changes: DBML source line numbers

Layer / File(s) Summary
Format and verify DBML source notes
cli/django_orm_lens/er_formats.py, cli/tests/test_er_formats.py
DBML notes add one to model.line_number. The test checks that notes reference source lines 4 and 13.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: frowningdev

Merge Risk: ⚪ Minimal · up to a1dc7

DBML notes now report the correct one-based model locations, with fixture-backed checks for both examples. No actionable merge risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: DBML now reports one-based model line numbers.
Linked Issues check Passed Issue #139 requires one-based DBML model source lines and an automated test. The PR changes cli/django_orm_lens/er_formats.py to add one to ParsedModel.line_number. It adds `test_dbml_notes_use_on…
Out of Scope Changes check Passed The reported changes are limited to DBML note formatting and its fixture-backed test. Both changes directly support issue #139. No unrelated change is identified.
Full details: Linked Issues check

Explanation

Issue #139 requires one-based DBML model source lines and an automated test. The PR changes cli/django_orm_lens/er_formats.py to add one to ParsedModel.line_number. It adds test_dbml_notes_use_one_based_source_lines in cli/tests/test_er_formats.py, covering lines 4 and 13. The reported test command passed 16 tests.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@FROWNINGdev
FROWNINGdev merged commit a2d0124 into FROWNINGdev:main Oct 19, 2026
18 checks passed
@FROWNINGdev

Copy link
Copy Markdown
Owner

Merged, thanks @syedmustafan. Clean one-line fix, and the test pins both models. I added the CHANGELOG entry in #165. Heads-up for next time: #139 had been offered to @vishalhabib99 in the thread, so please leave a short "I'll take this" on an issue before starting. It saves two people doing the same work.

FROWNINGdev added a commit that referenced this pull request Oct 19, 2026
#161 was branched before py-1.13.4 and its entry landed in the released section on merge. #160 had no entry.

Co-authored-by: FROWNINGdev <218313741+FROWNINGdev@users.noreply.github.com>
@FROWNINGdev FROWNINGdev mentioned this pull request Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DBML ER export notes model line numbers 0-based (off by one)

2 participants