-
Notifications
You must be signed in to change notification settings - Fork 14
avoid duplicate comment opts #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes update logic in the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
element/column.go(2 hunks)element/table.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
element/column.go (4)
sql-templates/option.go (2)
ColumnComment(52-60)TableComment(63-71)element/migration.go (1)
AddComment(138-154)options.go (1)
WithCommentGenerate(119-123)sql-builder/options.go (1)
WithCommentGenerate(98-102)
🔇 Additional comments (5)
element/column.go (2)
189-189: LGTM: Proper initialization of comment tracking flag.The
hasCommentboolean flag is correctly initialized to track when the first comment option is encountered.
253-259: LGTM: Correct implementation of duplicate comment prevention.The logic properly ensures that:
- Options are only appended to the SQL string when
hasCommentis false- The flag is set to true after encountering the first
ColumnOptionComment- This prevents duplicate comment options from being included in the SQL definition
This implementation aligns with the PR objective of avoiding duplicate comment options.
element/table.go (3)
265-286: LGTM: Correct filtering logic to exclude options after first comment.The filtering logic properly:
- Creates new slices to store options before the first comment
- Uses a
hasCommentflag to track when to stop adding options- Applies the same filtering to both new and old option slices
This ensures consistent handling with the changes in
element/column.go.
287-287: LGTM: Correct length comparison using filtered options.The length comparison now uses the filtered option slices
optNewandoptOld, which is consistent with the filtering approach.
297-299: LGTM: Correct variable usage for old options map.The
mOldmap correctly usesoptOldfor both iteration and map assignment.
Summary by CodeRabbit