Skip to content

Commit

Permalink
Support *.* syntax in MySQL GRANT statements
Browse files Browse the repository at this point in the history
Fixes #674
  • Loading branch information
nene committed Dec 7, 2023
1 parent d34557b commit 3e0689c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/languages/mariadb/mariadb.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,21 @@ export const mariadb: DialectOptions = {
],
paramTypes: { positional: true },
lineCommentTypes: ['--', '#'],
operators: ['%', ':=', '&', '|', '^', '~', '<<', '>>', '<=>', '&&', '||', '!'],
operators: [
'%',
':=',
'&',
'|',
'^',
'~',
'<<',
'>>',
'<=>',
'&&',
'||',
'!',
'*.*', // Not actually an operator
],
postProcess,
},
formatOptions: {
Expand Down
18 changes: 17 additions & 1 deletion src/languages/mysql/mysql.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,23 @@ export const mysql: DialectOptions = {
],
paramTypes: { positional: true },
lineCommentTypes: ['--', '#'],
operators: ['%', ':=', '&', '|', '^', '~', '<<', '>>', '<=>', '->', '->>', '&&', '||', '!'],
operators: [
'%',
':=',
'&',
'|',
'^',
'~',
'<<',
'>>',
'<=>',
'->',
'->>',
'&&',
'||',
'!',
'*.*', // Not actually an operator
],
postProcess,
},
formatOptions: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/singlestoredb/singlestoredb.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export const singlestoredb: DialectOptions = {
'::%',
':>',
'!:>',
'*.*', // Not actually an operator
],
postProcess,
},
Expand Down
7 changes: 7 additions & 0 deletions test/behavesLikeMariaDbFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,11 @@ export default function behavesLikeMariaDbFormatter(format: FormatFn) {
(1, 'Blah');
`);
});

// Issue #674
it('supports *.* syntax in GRANT statement', () => {
expect(format(`GRANT ALL ON *.* TO user2;`)).toBe(dedent`
GRANT ALL ON *.* TO user2;
`);
});
}

0 comments on commit 3e0689c

Please sign in to comment.