feat(pg): create columns as array and matrices - #185
Conversation
| choice( | ||
| seq(optional($.keyword_array), $._array_size_definition), | ||
| seq( $._array_size_definition, $._array_size_definition), | ||
| $.keyword_array, | ||
| ), | ||
| ), | ||
| _array_size_definition: $ => seq( | ||
| '[', | ||
| optional(field("size", alias($._integer, $.literal))), | ||
| ']' |
There was a problem hiding this comment.
| choice( | |
| seq(optional($.keyword_array), $._array_size_definition), | |
| seq( $._array_size_definition, $._array_size_definition), | |
| $.keyword_array, | |
| ), | |
| ), | |
| _array_size_definition: $ => seq( | |
| '[', | |
| optional(field("size", alias($._integer, $.literal))), | |
| ']' | |
| seq( | |
| optional($.keyword_array), | |
| repeat( | |
| seq( | |
| '[', | |
| optional(field("size", alias($._integer, $.literal))), | |
| ']' | |
| ) | |
| ) | |
| ), |
Postgres allows n-dimensional arrays > 2; repeat is 0 or more times so this should cover all possibilities
There was a problem hiding this comment.
the ARRAY keyword works only for 1D arrays
shouldn't it be repeat1() instead of repeat()?
There was a problem hiding this comment.
I have pushed a version, which allows for more dimensions. Unfortunately, it requires a conflict rule.
There was a problem hiding this comment.
repeat would allow array, array[n], array[n][n].... and cover all three at once (including the zero-repeats case of just the keyword), but it is more permissive than necessary if the keyword is only used with 1d arrays. I'm fine either way though.
if you replace the top and bottom options in your latest with seq($.keyword_array, optional($._array_size_definition)) do you still need the conflict rule?
There was a problem hiding this comment.
Ah yes, this resolves the conflict.
I have pushed it to my branch, but for some reason it does not show up in the PR 😕
Now it is there.
Closes #183