Skip to content
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

New default formatter for SQL #660

Merged
merged 1 commit into from
Mar 26, 2025
Merged

Conversation

neekolas
Copy link
Contributor

@neekolas neekolas commented Mar 21, 2025

TL;DR

Replace pgFormatter with SQLTools for SQL formatting in VS Code.

Why?

sqltools is more actively maintained. The previous formatter was dropped from the Cursor extensions marketplace. I also think the formatting is nicer.

What changed?

  • Replaced bradymholt.pgformatter with mtxr.sqltools in VS Code extensions recommendations
  • Updated VS Code settings to use SQLTools as the default SQL formatter
  • Configured SQLTools formatting options (uppercase reserved words, line spacing)
  • Reformatted all SQL queries in pkg/db/queries.sql with the new formatter

How to test?

  1. Install the SQLTools extension in VS Code
  2. Open any SQL file and verify that formatting works correctly on save
  3. Check that SQL queries maintain proper functionality while having improved readability
  4. Verify that SQL reserved words are properly capitalized

Why make this change?

SQLTools provides better SQL formatting capabilities than pgFormatter, with more configuration options and better integration with VS Code. The new formatting style improves SQL readability while maintaining the same functionality, making the codebase more maintainable.

Summary by CodeRabbit

  • New Features

    • Updated the workspace’s recommended SQL extension.
    • Enabled automatic formatting on save with enhanced SQL formatting settings.
  • Style

    • Refined the formatting of SQL queries to improve readability and consistency.

Copy link
Contributor

coderabbitai bot commented Mar 21, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes update the workspace configuration and SQL query formatting without altering underlying functionality. In VSCode configuration files, the recommendation for the SQL formatter has been changed from "bradymholt.pgformatter" to "mtxr.sqltools", and additional formatting settings such as editor.formatOnSave and sqltools configurations have been introduced. In the SQL files, query statements have been reformatted by removing extra line breaks and adjusting indentation, while keeping the original logic intact.

Changes

Files Change Summary
.vscode/extensions.json
.vscode/settings.json
Updated VSCode configuration: replaced "bradymholt.pgformatter" with "mtxr.sqltools" for SQL formatting; added editor.formatOnSave, disabled SQL query highlighting, and introduced new SQL tools formatting options (linesBetweenQueries, language, reservedWordCase).
pkg/db/queries.sql
pkg/db/queries/queries.sql.go
Reformatted SQL queries by consolidating line breaks and adjusting indentation for improved readability without changing the query logic.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant VSCode
    participant SQLTools

    Developer->>VSCode: Save SQL file
    VSCode->>SQLTools: Trigger auto-format (via editor.formatOnSave)
    SQLTools->>VSCode: Return formatted SQL code
    VSCode->>Developer: Update file with formatted SQL code
Loading

Possibly related PRs

  • New default formatter for SQL #660: The changes in the main PR are directly related to those in the retrieved PR, as both involve replacing the SQL formatter from "bradymholt.pgformatter" to "mtxr.sqltools" in the .vscode/extensions.json and .vscode/settings.json files.

Suggested reviewers

  • mkysel

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91bca49 and fcb0859.

📒 Files selected for processing (4)
  • .vscode/extensions.json (1 hunks)
  • .vscode/settings.json (1 hunks)
  • pkg/db/queries.sql (1 hunks)
  • pkg/db/queries/queries.sql.go (29 hunks)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@neekolas neekolas mentioned this pull request Mar 21, 2025
Copy link
Contributor Author

neekolas commented Mar 21, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

macroscopeapp bot commented Mar 21, 2025

Add sequence ID tracking and payer reporting

Added sequence ID tracking to unsettled usage records and implemented payer reporting functionality. Changed SQL formatting from pgFormatter to SQLTools. Modified database queries to track highest sequence IDs, added new queries for payer reporting, and created PayerReportManager to generate payment activity summaries.

📍Where to Start

The PayerReportManager implementation in manager.go which contains the core logic for generating payer reports.


Macroscope summarized fcb0859.

@neekolas neekolas force-pushed the 03-21-new_default_formatter_for_sql branch from 6f70e24 to 504bd53 Compare March 21, 2025 20:39
@neekolas neekolas marked this pull request as ready for review March 21, 2025 20:39
@neekolas neekolas requested a review from a team as a code owner March 21, 2025 20:39
@neekolas neekolas force-pushed the 03-21-new_default_formatter_for_sql branch from 504bd53 to 91c4036 Compare March 21, 2025 20:40
@neekolas neekolas force-pushed the 03-18-generate_payer_reports branch from de4ccfe to 10f84bb Compare March 21, 2025 20:40
@neekolas neekolas force-pushed the 03-18-generate_payer_reports branch from 10f84bb to 900622b Compare March 21, 2025 22:16
@neekolas neekolas force-pushed the 03-21-new_default_formatter_for_sql branch 3 times, most recently from fad8901 to 91bca49 Compare March 21, 2025 22:25
Copy link
Collaborator

@mkysel mkysel left a comment

Choose a reason for hiding this comment

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

no opinions on formatting.

Do we have some formatter in CI or that we run manually that will follow these? I don't use VScode so the extensions config won't affect my environment.

Copy link
Contributor Author

I have not yet found a SQL formatter that does all 3

  1. Runs in the editor
  2. Runs in CI
  3. Handles sqlc syntax

So, right now the formatting is unchecked.

Copy link
Contributor Author

neekolas commented Mar 26, 2025

Merge activity

  • Mar 26, 2:15 PM PDT: A user started a stack merge that includes this pull request via Graphite.
  • Mar 26, 2:16 PM PDT: Graphite rebased this pull request as part of a merge.
  • Mar 26, 2:18 PM PDT: A user merged this pull request with Graphite.

@neekolas neekolas changed the base branch from 03-18-generate_payer_reports to graphite-base/660 March 26, 2025 21:15
@neekolas neekolas changed the base branch from graphite-base/660 to main March 26, 2025 21:15
@neekolas neekolas force-pushed the 03-21-new_default_formatter_for_sql branch from 91bca49 to fcb0859 Compare March 26, 2025 21:16
@neekolas neekolas merged commit 422349f into main Mar 26, 2025
8 of 9 checks passed
@neekolas neekolas deleted the 03-21-new_default_formatter_for_sql branch March 26, 2025 21:18
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