Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Commit 4cc2e27

Browse files
committed
Allow trailing comma in CREATE VIRTUAL TABLE.
The offical SQLite parser allows trailing commas in VIRTUAL TABLE definitions.
1 parent 7ec7dfb commit 4cc2e27

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/grammar.pegjs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,12 +2426,29 @@ virtual_module
24262426
}
24272427

24282428
virtual_args "Module Arguments"
2429-
= sym_popen f:( virtual_arg_types ) o sym_pclose
2429+
= sym_popen o l:( virtual_args_loop )? o sym_pclose o
24302430
{
24312431
return {
2432-
'args': f
2432+
'args': {
2433+
'type': 'expression',
2434+
'variant': 'list',
2435+
'expression': isOkay(l) ? l : []
2436+
}
24332437
};
24342438
}
2439+
/**
2440+
* @note
2441+
* The offical SQLite parser allows trailing commas in VIRTUAL TABLE
2442+
* definitions.
2443+
*/
2444+
virtual_args_loop
2445+
= f:( virtual_arg_types ) b:( virtual_args_tail )* {
2446+
return flattenAll([ f, b ]).filter((arg) => isOkay(arg));
2447+
}
2448+
virtual_args_tail
2449+
= o sym_comma o a:( virtual_arg_types )? {
2450+
return a;
2451+
}
24352452

24362453
virtual_arg_types
24372454
= !( name o ( type_definition / column_constraint ) ) e:( expression ) o {

0 commit comments

Comments
 (0)