amaksimo opened a new pull request, #2367:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2367
## Summary
PostgreSQL allows the `CREATE SEQUENCE` option clauses (`INCREMENT`,
`MINVALUE`, `MAXVALUE`, `START`, `CACHE`, `CYCLE`) to appear in any order, per
the [docs][docs]. The previous parser was positional and rejected pg_dump
output, which emits `START` before `INCREMENT`:
```sql
CREATE SEQUENCE public.t_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
```
[docs]: https://www.postgresql.org/docs/current/sql-createsequence.html
## Changes
- Wrap the option-matching arms of `parse_create_sequence_options` in a loop
that breaks only when no clause matches the next token. The AST vector
preserves whatever order the source used.
- Add a doc-comment note on `Statement::CreateSequence` pointing to the PG
docs.
No performance impact; the per-clause work is unchanged.
## Tests
In `tests/sqlparser_common.rs` (the syntax is standard PostgreSQL also
accepted by `GenericDialect`):
- A pg_dump-shaped input parses to its canonical form.
- Two reorderings of the same clauses both round-trip with order preserved
(verifies the AST vector reflects source order).
- A duplicate-clause case is pinned as characterization (current permissive
behavior, not a contract).
- The original `INCREMENT`-first ordering still round-trips, guarding
regression.
`cargo test --all-features`, `cargo fmt --all`, and `cargo clippy
--all-targets --all-features -- -D warnings` all pass locally.
## History
Re-pitch of #2043 (closed by stale-bot after the author was unavailable for
two weeks). Addresses the review feedback from that PR:
- pure `else if … else break` loop without a bool sentinel
- `verified_stmt` round-trip tests in common
- duplicate-clause test case
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]