Repository navigation
Add branch workflow and selectable SQL dialects - #2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2124402227
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| def normalize_dialect(dialect: str) -> str: | ||
| normalized = dialect.strip().lower() | ||
| if normalized not in SUPPORTED_DIALECTS: |
There was a problem hiding this comment.
Accept valid SQLGlot dialect specifiers
Relax this membership check because it rejects dialect strings that SQLGlot itself accepts, such as configured dialect specifiers ("dialect, key=value") and plugin-provided dialect names loaded at runtime. Before this commit those values were passed through to sqlglot.parse, but now format/check/extract fail early with unsupported SQL dialect, which is a functional regression for users relying on SQLGlot’s documented dialect parsing behavior.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in f00c240.
normalize_dialect() now delegates validation to SQLGlot's Dialect.get_or_raise() instead of requiring an exact match against the built-in dialect list. I also added coverage for a configured dialect string such as postgres, normalization_strategy=case_sensitive.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds SQL dialect normalization/validation in the formatter, exposes supported dialects, updates CLI defaults/validation with error handling and a ChangesDialect Support Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@py_sql_cleaner/adapters/sqlglot_formatter.py`:
- Around line 69-77: The current functions
_has_redshift_explicit_dialect_keyword and _starts_with_command use naive
substring/prefix checks which misclassify identifiers/literals containing words
like COPY or ENCODE; replace these with token-aware matching by running the SQL
through sqlglot's tokenizer/lexer and inspecting token types/values so you only
match standalone keywords (e.g., TokenType.KEYWORD) and not parts of identifiers
or string literals. Specifically, in _has_redshift_explicit_dialect_keyword
tokenize sql and return True if any token value (normalized/uppercased) equals
one of REDSHIFT_EXPLICIT_DIALECT_KEYWORDS and the token type is a
keyword/identifier appropriate for matching; in _starts_with_command tokenize
and check the first non-whitespace/comment token exactly equals one of the
provided commands (by token value/type) rather than using startswith on raw
text. Ensure tokens from comments/strings are ignored and preserve current
return semantics.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: edf34ea3-9e80-4d7e-8ca8-57df1203cb9a
📒 Files selected for processing (9)
README.mdpy_sql_cleaner/adapters/sqlglot_formatter.pypy_sql_cleaner/application/format_source.pypy_sql_cleaner/cli/app.pytests/adapters/test_sqlglot_formatter.pytests/cli/test_format_command.pytests/core/test_detector.pywebsite/docs/intro.mdwebsite/docs/reference/commands.md
✅ Files skipped from review due to trivial changes (3)
- README.md
- website/docs/intro.md
- website/docs/reference/commands.md
Summary
--dialect/-dand adialectscommand.generic,mysql,postgres, andredshift.Validation
scripts/checkpassed locally via the pre-push hook.Notes
.coderabbit.yaml; the GitHub App is installed and reviewing this PR.Summary by CodeRabbit
New Features
Bug Fixes / UX
Documentation
Tests