Skip to content

Commit

Permalink
chore: bump to prettier 3
Browse files Browse the repository at this point in the history
  • Loading branch information
kevcodez committed Feb 1, 2024
1 parent e1777ed commit 3951a15
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actionsx/prettier@v2
- uses: actionsx/prettier@v3
with:
args: --check "{src,test}/**/*.ts"

Expand Down
142 changes: 81 additions & 61 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,15 @@
"pgsql-parser": "^13.3.0",
"pino": "^8.6.1",
"postgres-array": "^3.0.1",
"prettier": "^2.6.0",
"prettier-plugin-sql": "^0.13.0"
"prettier": "^3.2.4",
"prettier-plugin-sql": "0.17.0"
},
"devDependencies": {
"@types/crypto-js": "^4.1.1",
"@types/jest": "^29.2.4",
"@types/node": "^18.17.17",
"@types/pg": "^8.6.5",
"@types/pg-format": "^1.0.1",
"@types/prettier": "^2.7.3",
"cpy-cli": "^5.0.0",
"jest": "^29.3.1",
"nodemon": "^3.0.1",
Expand Down
7 changes: 5 additions & 2 deletions src/lib/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ interface DeparseReturnValues {
/**
* Formats a SQL string into a prettier-formatted SQL string.
*/
export function Format(sql: string, options: FormatterOptions = {}): FormatReturnValues {
export async function Format(
sql: string,
options: FormatterOptions = {}
): Promise<FormatReturnValues> {
try {
const formatted = prettier.format(sql, {
const formatted = await prettier.format(sql, {
...DEFAULT_FORMATTER_OPTIONS,
...options,
})
Expand Down
8 changes: 4 additions & 4 deletions src/lib/PostgresMetaColumnPrivileges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ where a.attrelid = ${literal(relationId)}
into col;
execute format(
'grant ${privilege_type} (%I) on %s to ${
grantee.toLowerCase() === 'public' ? 'public' : ident(grantee)
} ${is_grantable ? 'with grant option' : ''}',
grantee.toLowerCase() === 'public' ? 'public' : ident(grantee)
} ${is_grantable ? 'with grant option' : ''}',
col.attname,
col.attrelid::regclass
);`
Expand Down Expand Up @@ -114,8 +114,8 @@ where a.attrelid = ${literal(relationId)}
into col;
execute format(
'revoke ${privilege_type} (%I) on %s from ${
grantee.toLowerCase() === 'public' ? 'public' : ident(grantee)
}',
grantee.toLowerCase() === 'public' ? 'public' : ident(grantee)
}',
col.attname,
col.attrelid::regclass
);`
Expand Down
8 changes: 4 additions & 4 deletions src/lib/PostgresMetaColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,16 @@ BEGIN
IF v_conname IS NOT NULL THEN
EXECUTE format('ALTER TABLE ${ident(old!.schema)}.${ident(
old!.table
)} DROP CONSTRAINT %s', v_conname);
old!.table
)} DROP CONSTRAINT %s', v_conname);
END IF;
${
check !== null
? `
ALTER TABLE ${ident(old!.schema)}.${ident(old!.table)} ADD CONSTRAINT ${ident(
`${old!.table}_${old!.name}_check`
)} CHECK (${check});
`${old!.table}_${old!.name}_check`
)} CHECK (${check});
SELECT conkey into v_conkey FROM pg_constraint WHERE conname = ${literal(
`${old!.table}_${old!.name}_check`
Expand Down
8 changes: 4 additions & 4 deletions src/lib/PostgresMetaFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ export default class PostgresMetaFunctions {
AND f.identity_argument_types = ${literal(identityArgs)}
) != ${id} THEN
RAISE EXCEPTION 'Cannot find function "${currentFunc!.schema}"."${
currentFunc!.name
}"(${identityArgs})';
currentFunc!.name
}"(${identityArgs})';
END IF;
END IF;
Expand Down Expand Up @@ -242,8 +242,8 @@ export default class PostgresMetaFunctions {
): string {
return `
CREATE ${replace ? 'OR REPLACE' : ''} FUNCTION ${ident(schema!)}.${ident(name!)}(${
args?.join(', ') || ''
})
args?.join(', ') || ''
})
RETURNS ${return_type}
AS ${literal(definition)}
LANGUAGE ${language}
Expand Down
Loading

0 comments on commit 3951a15

Please sign in to comment.