Skip to content

add identity_column to AIGeneratedTableSettings#1732

Merged
Artuomka merged 1 commit into
mainfrom
backend_identity_field_prompt
Apr 24, 2026
Merged

add identity_column to AIGeneratedTableSettings#1732
Artuomka merged 1 commit into
mainfrom
backend_identity_field_prompt

Conversation

@Artuomka
Copy link
Copy Markdown
Collaborator

@Artuomka Artuomka commented Apr 24, 2026

Co-authored-by: Copilot copilot@github.com

Summary by CodeRabbit

  • New Features

    • Table settings configuration now supports specifying an identity column for each table
    • Automatic validation ensures the selected identity column exists within the available table columns
  • Chores

    • Refactored table field validation logic for improved code organization

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 24, 2026 10:09
@Artuomka Artuomka enabled auto-merge April 24, 2026 10:09
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

📝 Walkthrough

Walkthrough

The AI-generated table settings schema is extended to include an identity_column field with validation against discovered column names, writing it to TableSettingsEntity or forcing null if invalid. A predicate for computing required non-nullable fields with no default is also reformatted.

Changes

Cohort / File(s) Summary
AI Service Schema Extension
backend/src/entities/ai/ai.service.ts
Extended table settings schema with identity_column field, added validation logic against discovered columns, updated prompt/output contract, and refactored predicate for required non-nullable field computation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰✨ A column's identity now shines so bright,
Validation checks ensure it's just right,
The schema grows with care refined,
One file touched, two patterns aligned! 🎯

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly and concisely describes the main change: adding an identity_column field to AIGeneratedTableSettings.
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.
Security Check ✅ Passed The PR properly implements security controls for the new identity_column field by validating it against an actual whitelist of discovered table columns and setting invalid values to null. The validated value is then safely used in parameterized database queries or properly escaped identifier contexts across all supported database drivers.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backend_identity_field_prompt

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 and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the AI-driven table settings generation so the model can propose an identity_column (a human-readable identifier column) and the backend persists it into generated TableSettingsEntity records.

Changes:

  • Added identity_column to the AIGeneratedTableSettings contract used for parsing AI responses.
  • Extended the AI prompt and the required JSON response example to include identity_column.
  • Mapped/validated identity_column from the AI response into TableSettingsEntity.identity_column (restricted to existing columns, otherwise null).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@backend/src/entities/ai/ai.service.ts`:
- Line 139: Remove the trailing space at the end of the prompt string in
backend/src/entities/ai/ai.service.ts (the prompt text ending with "use null.");
locate the string literal that contains "identity_column: The column that best
identifies a row in human-readable format... use null." and trim the trailing
whitespace (or apply .trim() where the prompt is constructed) so the prompt sent
to the model no longer includes the extra space.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 328f0bb5-5669-4ad3-9f4e-724228063428

📥 Commits

Reviewing files that changed from the base of the PR and between 253bc82 and 69c7e13.

📒 Files selected for processing (1)
  • backend/src/entities/ai/ai.service.ts

5. ordering: Default sort order - either "ASC" or "DESC" (use "DESC" for tables with timestamps to show newest first)
6. ordering_field: Column name to sort by default (prefer created_at, updated_at, or primary key)
7. widgets: For each column, suggest the best widget type from: ${widgetTypes}
8. identity_column: The column that best identifies a row in human-readable format. This is shown when other tables reference this table via foreign keys, so users see meaningful data instead of just IDs. Choose columns like: name, title, email, username, full_name, label, or any descriptive text field. If no good candidate exists, use null.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor: trailing whitespace in prompt string.

There is a trailing space after use null. at the end of line 139. Not functional, but it slightly bloats the prompt sent to the model. Consider trimming.

✂️ Proposed fix
-8. identity_column: The column that best identifies a row in human-readable format. This is shown when other tables reference this table via foreign keys, so users see meaningful data instead of just IDs. Choose columns like: name, title, email, username, full_name, label, or any descriptive text field. If no good candidate exists, use null. 
+8. identity_column: The column that best identifies a row in human-readable format. This is shown when other tables reference this table via foreign keys, so users see meaningful data instead of just IDs. Choose columns like: name, title, email, username, full_name, label, or any descriptive text field. If no good candidate exists, use null.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
8. identity_column: The column that best identifies a row in human-readable format. This is shown when other tables reference this table via foreign keys, so users see meaningful data instead of just IDs. Choose columns like: name, title, email, username, full_name, label, or any descriptive text field. If no good candidate exists, use null.
8. identity_column: The column that best identifies a row in human-readable format. This is shown when other tables reference this table via foreign keys, so users see meaningful data instead of just IDs. Choose columns like: name, title, email, username, full_name, label, or any descriptive text field. If no good candidate exists, use null.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/src/entities/ai/ai.service.ts` at line 139, Remove the trailing space
at the end of the prompt string in backend/src/entities/ai/ai.service.ts (the
prompt text ending with "use null."); locate the string literal that contains
"identity_column: The column that best identifies a row in human-readable
format... use null." and trim the trailing whitespace (or apply .trim() where
the prompt is constructed) so the prompt sent to the model no longer includes
the extra space.

@Artuomka Artuomka merged commit cf964f0 into main Apr 24, 2026
22 of 23 checks passed
@Artuomka Artuomka deleted the backend_identity_field_prompt branch April 24, 2026 10:19
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.

2 participants