-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Release4 #36600
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
Release4 #36600
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,4 @@ | ||||||||||||||
| import { BaseQueryGenerator } from "../BaseQueryGenerator"; | ||||||||||||||
| import { formatDialect, sql } from "sql-formatter"; | ||||||||||||||
| import type { | ||||||||||||||
| ActionConfigurationSQL, | ||||||||||||||
| WidgetQueryGenerationConfig, | ||||||||||||||
|
|
@@ -11,7 +10,7 @@ import without from "lodash/without"; | |||||||||||||
| import { DatasourceConnectionMode } from "entities/Datasource"; | ||||||||||||||
|
|
||||||||||||||
| export default abstract class MSSQL extends BaseQueryGenerator { | ||||||||||||||
| private static buildSelect( | ||||||||||||||
| private static async buildSelect( | ||||||||||||||
| widgetConfig: WidgetQueryGenerationConfig, | ||||||||||||||
| formConfig: WidgetQueryGenerationFormConfig, | ||||||||||||||
| ) { | ||||||||||||||
|
|
@@ -77,6 +76,8 @@ export default abstract class MSSQL extends BaseQueryGenerator { | |||||||||||||
| { template: "", params: [] } as { template: string; params: string[] }, | ||||||||||||||
| ); | ||||||||||||||
|
|
||||||||||||||
| const { formatDialect, sql } = await import("sql-formatter"); | ||||||||||||||
|
|
||||||||||||||
|
Comment on lines
+79
to
+80
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider the impact of dynamic imports on performance. Dynamically importing Apply the following changes: At the top of the file, add: +import { formatDialect, sql } from "sql-formatter";Then, remove the dynamic import inside the -const { formatDialect, sql } = await import("sql-formatter");This adjustment will improve the efficiency of your code by loading the module once during the initial load rather than on every function call. 📝 Committable suggestion
Suggested change
|
||||||||||||||
| //formats sql string | ||||||||||||||
| const res = formatDialect(template, { | ||||||||||||||
| params, | ||||||||||||||
|
|
@@ -196,15 +197,15 @@ export default abstract class MSSQL extends BaseQueryGenerator { | |||||||||||||
| }; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| public static build( | ||||||||||||||
| public static async build( | ||||||||||||||
| widgetConfig: WidgetQueryGenerationConfig, | ||||||||||||||
| formConfig: WidgetQueryGenerationFormConfig, | ||||||||||||||
| pluginInitalValues: { actionConfiguration: ActionConfigurationSQL }, | ||||||||||||||
| ) { | ||||||||||||||
| const allBuildConfigs = []; | ||||||||||||||
|
|
||||||||||||||
| if (widgetConfig.select) { | ||||||||||||||
| allBuildConfigs.push(this.buildSelect(widgetConfig, formConfig)); | ||||||||||||||
| allBuildConfigs.push(await this.buildSelect(widgetConfig, formConfig)); | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace 'this' with the class name for clarity in static methods. In static contexts, using Apply the following diff to make the change: -allBuildConfigs.push(await this.buildSelect(widgetConfig, formConfig));
+allBuildConfigs.push(await MSSQL.buildSelect(widgetConfig, formConfig));By explicitly using 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if ( | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,4 @@ | ||||||
| import { BaseQueryGenerator } from "../BaseQueryGenerator"; | ||||||
| import { formatDialect, mysql } from "sql-formatter"; | ||||||
| import type { | ||||||
| ActionConfigurationSQL, | ||||||
| WidgetQueryGenerationConfig, | ||||||
|
|
@@ -11,7 +10,7 @@ import without from "lodash/without"; | |||||
| import { DatasourceConnectionMode } from "entities/Datasource"; | ||||||
|
|
||||||
| export default abstract class MySQL extends BaseQueryGenerator { | ||||||
| private static buildSelect( | ||||||
| private static async buildSelect( | ||||||
| widgetConfig: WidgetQueryGenerationConfig, | ||||||
| formConfig: WidgetQueryGenerationFormConfig, | ||||||
| ) { | ||||||
|
|
@@ -76,6 +75,7 @@ export default abstract class MySQL extends BaseQueryGenerator { | |||||
| }, | ||||||
| { template: "", params: [] } as { template: string; params: string[] }, | ||||||
| ); | ||||||
| const { formatDialect, mysql } = await import("sql-formatter"); | ||||||
|
|
||||||
| //formats sql string | ||||||
| const res = formatDialect(template, { | ||||||
|
|
@@ -196,15 +196,15 @@ export default abstract class MySQL extends BaseQueryGenerator { | |||||
| }; | ||||||
| } | ||||||
|
|
||||||
| public static build( | ||||||
| public static async build( | ||||||
| widgetConfig: WidgetQueryGenerationConfig, | ||||||
| formConfig: WidgetQueryGenerationFormConfig, | ||||||
| pluginInitalValues: { actionConfiguration: ActionConfigurationSQL }, | ||||||
| ) { | ||||||
| const allBuildConfigs = []; | ||||||
|
|
||||||
| if (widgetConfig.select) { | ||||||
| allBuildConfigs.push(this.buildSelect(widgetConfig, formConfig)); | ||||||
| allBuildConfigs.push(await this.buildSelect(widgetConfig, formConfig)); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify Static Context by Replacing Using Consider updating the code as follows: -allBuildConfigs.push(await this.buildSelect(widgetConfig, formConfig));
+allBuildConfigs.push(await MySQL.buildSelect(widgetConfig, formConfig));📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||
| } | ||||||
|
|
||||||
| if ( | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import { BaseQueryGenerator } from "../BaseQueryGenerator"; | ||
| import { formatDialect, postgresql } from "sql-formatter"; | ||
| import type { | ||
| ActionConfigurationSQL, | ||
| WidgetQueryGenerationConfig, | ||
|
|
@@ -11,7 +10,7 @@ import { without } from "lodash"; | |
| import { DatasourceConnectionMode } from "entities/Datasource"; | ||
|
|
||
| export default abstract class PostgreSQL extends BaseQueryGenerator { | ||
| private static buildSelect( | ||
| private static async buildSelect( | ||
| widgetConfig: WidgetQueryGenerationConfig, | ||
| formConfig: WidgetQueryGenerationFormConfig, | ||
| ) { | ||
|
|
@@ -87,6 +86,8 @@ export default abstract class PostgreSQL extends BaseQueryGenerator { | |
| { template: "", params: {} }, | ||
| ); | ||
| //formats sql string | ||
| const { formatDialect, postgresql } = await import("sql-formatter"); | ||
|
|
||
| const res = formatDialect(template, { | ||
|
Comment on lines
+89
to
91
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider statically importing 'sql-formatter' for improved performance While dynamic imports are useful, importing You can move the import to the top of your file: import { formatDialect, postgresql } from "sql-formatter";And then remove the dynamic import inside - const { formatDialect, postgresql } = await import("sql-formatter"); |
||
| params, | ||
| dialect: postgresql, | ||
|
|
@@ -205,15 +206,15 @@ export default abstract class PostgreSQL extends BaseQueryGenerator { | |
| }; | ||
| } | ||
|
|
||
| public static build( | ||
| public static async build( | ||
| widgetConfig: WidgetQueryGenerationConfig, | ||
| formConfig: WidgetQueryGenerationFormConfig, | ||
| pluginInitalValues: { actionConfiguration: ActionConfigurationSQL }, | ||
| ) { | ||
| const allBuildConfigs = []; | ||
|
|
||
| if (widgetConfig.select) { | ||
| allBuildConfigs.push(this.buildSelect(widgetConfig, formConfig)); | ||
| allBuildConfigs.push(await this.buildSelect(widgetConfig, formConfig)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace 'this' with the class name in static context In static methods, using Apply this diff to correct the issue: - allBuildConfigs.push(await this.buildSelect(widgetConfig, formConfig));
+ allBuildConfigs.push(await PostgreSQL.buildSelect(widgetConfig, formConfig));
🧰 Tools🪛 Biome
|
||
| } | ||
|
|
||
| if ( | ||
|
|
||
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.
💡 Codebase verification
Recommendation on
asyncKeyword inGSheets.buildMethodIt appears that the
buildmethod inGSheetsdoes not perform any asynchronous operations. Therefore, theasynckeyword may be unnecessary. I recommend removing theasynckeyword to simplify the code unless there are plans to introduce asynchronous functionality in the near future.app/client/src/WidgetQueryGenerators/GSheets/index.tsstatic build🔗 Analysis chain
Class, let's examine this change closely.
The addition of the
asynckeyword to thebuildmethod is an interesting modification. While it doesn't appear to introduce any immediate issues, I have a few points for us to consider:This change suggests that we're preparing for asynchronous operations within this method. However, I don't see any
awaitkeywords or Promise-returning function calls in the method body.If there are plans to introduce asynchronous operations in the future, it would be beneficial to add a comment explaining this intention. This will help your fellow students... I mean, developers, understand the reasoning behind this change.
If there are no immediate plans for asynchronous operations, we should consider whether this change is necessary at this time.
To ensure we fully understand the impact of this change, let's do a little homework. Run the following command to check for any other occurrences of this method in the codebase:
This will help us identify any areas where we might need to update method calls or handle the returned Promise.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 81
Script:
Length of output: 3143
Script:
Length of output: 211
Script:
Length of output: 904
Script:
Length of output: 200