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

chore: add spotless for sql files for postgres #37016

Open
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

AnaghHegde
Copy link
Member

@AnaghHegde AnaghHegde commented Oct 23, 2024

Description

Add spotless check for SQL files.

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11549507562
Commit: 5614181
Cypress dashboard.
Tags: @tag.All
Spec:


Mon, 28 Oct 2024 11:13:16 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Added user guidance in SQL templates to prompt users for valid table names.
  • Bug Fixes
    • Improved formatting of SQL statements for better readability across various plugins.
  • Chores
    • Updated configuration to include SQL files for formatting by the Spotless Maven plugin.

@AnaghHegde AnaghHegde self-assigned this Oct 23, 2024
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Oct 23, 2024
Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (2)
app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/SELECT.sql (1)

Line range hint 4-4: Add newline at end of file.

SQL files should end with a newline character to follow standard text file conventions.

 -- Please enter a valid table name and hit RUN
+
app/server/pom.xml (1)

137-137: LGTM! Consider enhancing SQL formatting configuration.

The SQL file inclusion is correctly configured.

Consider adding SQL-specific configurations:

  1. Exclude generated SQL files:
 <includes>
     <include>**/*.sql</include>
 </includes>
+<excludes>
+    <exclude>**/generated/**/*.sql</exclude>
+</excludes>
  1. Add SQL-specific prettier configuration similar to the JSON section:
<sql>
    <prettier>
        <config>
            <keywordCase>upper</keywordCase>
            <tabWidth>2</tabWidth>
        </config>
    </prettier>
</sql>
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a8da0e1 and 5614181.

📒 Files selected for processing (22)
  • app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/CREATE.sql (1 hunks)
  • app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/SELECT.sql (1 hunks)
  • app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/UPDATE.sql (1 hunks)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/CREATE.sql (1 hunks)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/DELETE.sql (1 hunks)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/UPDATE.sql (1 hunks)
  • app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/DELETE.sql (1 hunks)
  • app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/INSERT.sql (1 hunks)
  • app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/UPDATE.sql (1 hunks)
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/CREATE.sql (1 hunks)
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/DELETE.sql (1 hunks)
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/SELECT.sql (1 hunks)
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/UPDATE.sql (1 hunks)
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/CREATE.sql (1 hunks)
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/DELETE.sql (1 hunks)
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/SELECT.sql (1 hunks)
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/UPDATE.sql (1 hunks)
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/CREATE.sql (1 hunks)
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/DELETE.sql (1 hunks)
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/SELECT.sql (1 hunks)
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/UPDATE.sql (1 hunks)
  • app/server/pom.xml (1 hunks)
✅ Files skipped from review due to trivial changes (19)
  • app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/CREATE.sql
  • app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/SELECT.sql
  • app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/UPDATE.sql
  • app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/CREATE.sql
  • app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/DELETE.sql
  • app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/UPDATE.sql
  • app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/DELETE.sql
  • app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/INSERT.sql
  • app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/UPDATE.sql
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/CREATE.sql
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/DELETE.sql
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/UPDATE.sql
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/CREATE.sql
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/DELETE.sql
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/SELECT.sql
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/UPDATE.sql
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/CREATE.sql
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/DELETE.sql
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/UPDATE.sql
🧰 Additional context used
🔇 Additional comments (2)
app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/SELECT.sql (1)

1-1: LGTM! Proper SQL comment syntax added.

The addition of SQL comment delimiter improves template validity while maintaining clear user guidance.

Also applies to: 3-3

app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/SELECT.sql (1)

3-3: LGTM! Clear and helpful comment.

The comment follows proper SQL syntax and provides clear guidance to users.

@abhvsn
Copy link
Contributor

abhvsn commented Oct 24, 2024

@AnaghHegde can we first look into how this will affect the postgres migration? So that existing migrations will not cause any issues because of different checksum values.

@AnaghHegde
Copy link
Member Author

@abhvsn Your concern is valid and is handled in the PR - #37103

@appsmithorg appsmithorg deleted a comment from coderabbitai bot Oct 25, 2024
@AnaghHegde AnaghHegde added the ok-to-test Required label for CI label Oct 25, 2024
Copy link
Contributor

coderabbitai bot commented Oct 25, 2024

Walkthrough

The changes involve formatting adjustments across various SQL template files within multiple plugins, including CREATE.sql, SELECT.sql, UPDATE.sql, DELETE.sql, and others. The modifications primarily focus on the indentation of SQL statements for improved readability and the addition of comments in some cases. Additionally, a new inclusion for SQL files has been added to the Spotless Maven Plugin configuration in the pom.xml file, allowing for the automated formatting of these SQL files.

Changes

File Path Change Summary
app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/*.sql Adjusted indentation for INSERT and UPDATE statements for readability; added comment in SELECT.sql.
app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/*.sql Adjusted indentation for INSERT and UPDATE statements; added newline in DELETE.sql.
app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/*.sql Adjusted indentation for INSERT and UPDATE statements; added newline in DELETE.sql.
app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/*.sql Adjusted indentation for INSERT and UPDATE statements; added comment in SELECT.sql; added newline in DELETE.sql.
app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/*.sql Adjusted indentation for INSERT and UPDATE statements; added newline in DELETE.sql.
app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/*.sql Adjusted indentation for INSERT and UPDATE statements; added newline in DELETE.sql.
app/server/pom.xml Added inclusion for SQL files to Spotless Maven Plugin configuration for formatting.

Possibly related PRs

Suggested labels

Task, Workflows Pod, Workflows Product

Suggested reviewers

  • sharat87
  • abhvsn

🎉 In the realm of SQL, neatness is key,
Indentations aligned, as clear as can be!
Comments now shine, guiding the way,
For users to follow, come work or play.
With Spotless in charge, our code looks so bright,
Cheers to the changes, everything feels right! 🎊


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 resolve resolve all the CodeRabbit review comments.
  • @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.

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.

Copy link
Contributor

@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: 0

🧹 Outside diff range and nitpick comments (2)
app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/SELECT.sql (1)

3-3: LGTM! The comment addition improves template usability.

The added instruction is clear and uses proper SQL comment syntax.

Consider adding a blank line before the comment for better readability:

SELECT * FROM <<your_table_name>> LIMIT 10;

+
-- Please enter a valid table name and hit RUN
app/server/pom.xml (1)

Inconsistent SQL formatting detected across the codebase

The codebase currently has mixed SQL formatting:

  • Template SQL files in plugin directories use tab indentation
  • Test SQL files use space indentation
  • No documented SQL formatting standards found

The proposed tab-based formatting with 2 spaces per tab will introduce a third formatting style, further increasing inconsistency.

🔗 Analysis chain

Line range hint 137-144: Verify formatting configuration impact.

The current formatting configuration uses tabs with 2 spaces. Ensure this aligns with your PostgreSQL coding standards and won't cause issues with existing SQL files.

Let's check the current formatting of SQL files:

Consider documenting the SQL formatting standards in a README or contributing guidelines to ensure consistency across the team.


Let me gather more information about SQL formatting standards in the project.

This will help us understand if there are any documented standards and what indentation style is currently prevalent in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check indentation in existing SQL files
fd -e sql -t f --exec head -n 10

Length of output: 3134


Script:

#!/bin/bash
# Check for SQL formatting documentation
fd -e md -t f --exec grep -l -i "sql.*format\|indent" {}

# Check if there are any SQL files with tab indentation
fd -e sql -t f --exec grep -l "^	" {}

# Check if there are any SQL files with space indentation
fd -e sql -t f --exec grep -l "^  \|^    " {}

Length of output: 1222

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a8da0e1 and 5614181.

📒 Files selected for processing (22)
  • app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/CREATE.sql (1 hunks)
  • app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/SELECT.sql (1 hunks)
  • app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/UPDATE.sql (1 hunks)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/CREATE.sql (1 hunks)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/DELETE.sql (1 hunks)
  • app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/UPDATE.sql (1 hunks)
  • app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/DELETE.sql (1 hunks)
  • app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/INSERT.sql (1 hunks)
  • app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/UPDATE.sql (1 hunks)
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/CREATE.sql (1 hunks)
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/DELETE.sql (1 hunks)
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/SELECT.sql (1 hunks)
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/UPDATE.sql (1 hunks)
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/CREATE.sql (1 hunks)
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/DELETE.sql (1 hunks)
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/SELECT.sql (1 hunks)
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/UPDATE.sql (1 hunks)
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/CREATE.sql (1 hunks)
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/DELETE.sql (1 hunks)
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/SELECT.sql (1 hunks)
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/UPDATE.sql (1 hunks)
  • app/server/pom.xml (1 hunks)
✅ Files skipped from review due to trivial changes (20)
  • app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/CREATE.sql
  • app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/SELECT.sql
  • app/server/appsmith-plugins/mssqlPlugin/src/main/resources/templates/UPDATE.sql
  • app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/CREATE.sql
  • app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/DELETE.sql
  • app/server/appsmith-plugins/mysqlPlugin/src/main/resources/templates/UPDATE.sql
  • app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/DELETE.sql
  • app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/INSERT.sql
  • app/server/appsmith-plugins/oraclePlugin/src/main/resources/templates/UPDATE.sql
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/CREATE.sql
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/DELETE.sql
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/SELECT.sql
  • app/server/appsmith-plugins/postgresPlugin/src/main/resources/templates/UPDATE.sql
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/CREATE.sql
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/DELETE.sql
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/SELECT.sql
  • app/server/appsmith-plugins/redshiftPlugin/src/main/resources/templates/UPDATE.sql
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/CREATE.sql
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/DELETE.sql
  • app/server/appsmith-plugins/snowflakePlugin/src/main/resources/templates/UPDATE.sql
🔇 Additional comments (1)
app/server/pom.xml (1)

137-137: 🛠️ Refactor suggestion

Consider restricting SQL formatting scope.

The pattern **/*.sql will format all SQL files in the project. Consider restricting it to specific directories to avoid affecting migration files.

Let's verify the SQL files that would be affected:

Consider using a more specific pattern to exclude migration files:

-<include>**/*.sql</include>
+<include>**/plugins/**/templates/**/*.sql</include>
✅ Verification successful

SQL formatting scope is correctly defined

The current pattern **/*.sql is appropriate as all SQL files in the codebase are template files within plugin directories, except for test data files in the Cypress directory. There are no migration files that could be affected by formatting.

  • SQL files found:
    • Plugin template files: app/server/appsmith-plugins/*/src/main/resources/templates/*.sql
    • Cypress test data: app/client/cypress/init-*-dump-for-test.sql

The suggested pattern restriction is unnecessary since there are no migration files to protect.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# List all SQL files that would be formatted
fd -e sql -t f

# Check for migration files specifically
fd -e sql -t f | grep -i migr

Length of output: 2153

@AnaghHegde AnaghHegde added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Oct 25, 2024
Copy link

github-actions bot commented Nov 4, 2024

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants