LucaCappelletti94 commented on code in PR #2627:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2627#discussion_r4282515437
##########
src/ast/mod.rs:
##########
@@ -6913,8 +6913,17 @@ pub struct OnConflict {
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
/// Target specification for an `ON CONFLICT` clause.
pub enum ConflictTarget {
- /// Target specified as a list of columns.
- Columns(Vec<Ident>),
+ /// Target specified as a list of columns, optionally followed by
PostgreSQL's
+ /// `WHERE index_predicate`, which lets a partial unique index be inferred
as the arbiter:
+ /// `ON CONFLICT (a) WHERE b > 0 DO ...`.
+ ///
+ /// See <https://www.postgresql.org/docs/current/sql-insert.html>
Review Comment:
You should say SQLite accepts this predicate too. Its upsert grammar has the
same `( indexed-column, ... ) WHERE expr` target, and the parser reads it in
every dialect. SQLite 3.51.1 runs `INSERT INTO t VALUES (1, 2, 3) ON CONFLICT
(a) WHERE b > 0 DO NOTHING` and rejects `ON CONFLICT WHERE b > 0`. With the doc
naming only PostgreSQL, a later change could gate the parse to PostgreSQL and
drop SQLite without anyone noticing.
```suggestion
/// Target specified as a list of columns, optionally followed by
/// `WHERE index_predicate`, which lets a partial unique index be
inferred as the arbiter:
/// `ON CONFLICT (a) WHERE b > 0 DO ...`. PostgreSQL and SQLite both
accept the predicate.
///
/// See <https://www.postgresql.org/docs/current/sql-insert.html>
/// and <https://www.sqlite.org/lang_upsert.html>
```
--
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]