diff --git a/package-lock.json b/package-lock.json index a214a0d5..27cf69c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "lru-cache": "^6.0.0", "node-fetch": "^3.3.1", "octokit": "^2.0.14", - "sql-formatter": "^13.1.0" + "sql-formatter": "^14.0.0" }, "devDependencies": { "@halcyontech/vscode-ibmi-types": "^2.0.0", @@ -3943,9 +3943,9 @@ "dev": true }, "node_modules/sql-formatter": { - "version": "13.1.0", - "resolved": "https://registry.npmjs.org/sql-formatter/-/sql-formatter-13.1.0.tgz", - "integrity": "sha512-/nZQXuN7KzipFNM20ko+dHY4kOr9rymSfZLUDED8rhx3m8OK5y74jcyN+y1L51ZqHqiB0kp40VdpZP99uWvQdA==", + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/sql-formatter/-/sql-formatter-14.0.0.tgz", + "integrity": "sha512-VcHYMRvZqg3RNjjxNB/puT9O1hR5QLXTvgTaBtxXcvmRQwSnH9M+oW2Ti+uFuVVU8HoNlOjU2uKHv8c0FQNsdQ==", "dependencies": { "argparse": "^2.0.1", "get-stdin": "=8.0.0", @@ -8066,9 +8066,9 @@ "dev": true }, "sql-formatter": { - "version": "13.1.0", - "resolved": "https://registry.npmjs.org/sql-formatter/-/sql-formatter-13.1.0.tgz", - "integrity": "sha512-/nZQXuN7KzipFNM20ko+dHY4kOr9rymSfZLUDED8rhx3m8OK5y74jcyN+y1L51ZqHqiB0kp40VdpZP99uWvQdA==", + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/sql-formatter/-/sql-formatter-14.0.0.tgz", + "integrity": "sha512-VcHYMRvZqg3RNjjxNB/puT9O1hR5QLXTvgTaBtxXcvmRQwSnH9M+oW2Ti+uFuVVU8HoNlOjU2uKHv8c0FQNsdQ==", "requires": { "argparse": "^2.0.1", "get-stdin": "=8.0.0", diff --git a/package.json b/package.json index 22032184..9e6c48d6 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,17 @@ "default": {}, "additionalProperties": true }, + "vscode-db2i.sqlFormat.identifierCase": { + "type": "string", + "description": "SQL formatting options: Lowercase or uppercase SQL identifiers", + "default": "preserve", + "enum": ["lower", "upper", "preserve"], + "enumDescriptions": [ + "Format SQL identifiers in lowercase", + "Format SQL identifiers in uppercase", + "Preserve the current formatting of SQL identifiers" + ] + }, "vscode-db2i.sqlFormat.keywordCase": { "type": "string", "description": "SQL formatting options: Lowercase or uppercase SQL keywords", @@ -598,7 +609,7 @@ "csv": "^6.1.3", "node-fetch": "^3.3.1", "octokit": "^2.0.14", - "sql-formatter": "^13.1.0", + "sql-formatter": "^14.0.0", "lru-cache": "^6.0.0" } } diff --git a/src/database/statement.ts b/src/database/statement.ts index 301a68af..a07bfb4e 100644 --- a/src/database/statement.ts +++ b/src/database/statement.ts @@ -2,16 +2,18 @@ import { getInstance } from "../base"; import Configuration from "../configuration"; -import {format, FormatOptionsWithLanguage, KeywordCase} from "sql-formatter" +import {format, FormatOptionsWithLanguage, IdentifierCase, KeywordCase} from "sql-formatter" export default class Statement { static format(sql: string, options: FormatOptionsWithLanguage = {}) { + const identifierCase: IdentifierCase = (Configuration.get(`sqlFormat.identifierCase`) || `preserve`); const keywordCase: KeywordCase = (Configuration.get(`sqlFormat.keywordCase`) || `lower`); return format(sql, { ...options, language: `db2i`, // Defaults to "sql" (see the above list of supported dialects) linesBetweenQueries: 2, // Defaults to 1 - keywordCase: keywordCase + identifierCase: identifierCase, + keywordCase: keywordCase, }); }