Skip to content

Commit 3e0689c

Browse files
committed
Support *.* syntax in MySQL GRANT statements
Fixes #674
1 parent d34557b commit 3e0689c

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

src/languages/mariadb/mariadb.formatter.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,21 @@ export const mariadb: DialectOptions = {
293293
],
294294
paramTypes: { positional: true },
295295
lineCommentTypes: ['--', '#'],
296-
operators: ['%', ':=', '&', '|', '^', '~', '<<', '>>', '<=>', '&&', '||', '!'],
296+
operators: [
297+
'%',
298+
':=',
299+
'&',
300+
'|',
301+
'^',
302+
'~',
303+
'<<',
304+
'>>',
305+
'<=>',
306+
'&&',
307+
'||',
308+
'!',
309+
'*.*', // Not actually an operator
310+
],
297311
postProcess,
298312
},
299313
formatOptions: {

src/languages/mysql/mysql.formatter.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,23 @@ export const mysql: DialectOptions = {
260260
],
261261
paramTypes: { positional: true },
262262
lineCommentTypes: ['--', '#'],
263-
operators: ['%', ':=', '&', '|', '^', '~', '<<', '>>', '<=>', '->', '->>', '&&', '||', '!'],
263+
operators: [
264+
'%',
265+
':=',
266+
'&',
267+
'|',
268+
'^',
269+
'~',
270+
'<<',
271+
'>>',
272+
'<=>',
273+
'->',
274+
'->>',
275+
'&&',
276+
'||',
277+
'!',
278+
'*.*', // Not actually an operator
279+
],
264280
postProcess,
265281
},
266282
formatOptions: {

src/languages/singlestoredb/singlestoredb.formatter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export const singlestoredb: DialectOptions = {
273273
'::%',
274274
':>',
275275
'!:>',
276+
'*.*', // Not actually an operator
276277
],
277278
postProcess,
278279
},

test/behavesLikeMariaDbFormatter.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,11 @@ export default function behavesLikeMariaDbFormatter(format: FormatFn) {
182182
(1, 'Blah');
183183
`);
184184
});
185+
186+
// Issue #674
187+
it('supports *.* syntax in GRANT statement', () => {
188+
expect(format(`GRANT ALL ON *.* TO user2;`)).toBe(dedent`
189+
GRANT ALL ON *.* TO user2;
190+
`);
191+
});
185192
}

0 commit comments

Comments
 (0)