File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3020,9 +3020,17 @@ private function translate_insert_or_replace_body_in_non_strict_mode(
30203020 }
30213021
30223022 // 6. Wrap the original insert VALUES or SELECT expression in a FROM clause.
3023- $ values = 'insertFromConstructor ' === $ node ->rule_name
3023+ $ values = 'insertFromConstructor ' === $ node ->rule_name
30243024 ? $ node ->get_first_child_node ( 'insertValues ' )
30253025 : $ node ->get_first_child_node ( 'queryExpressionOrParens ' );
3026+
3027+ /*
3028+ * The "WHERE true" suffix is used to avoid parsing ambiguity in SQLite.
3029+ * When an "ON CONFLICT" clause is used and there is no "WHERE", SQLite
3030+ * doesn't know if "ON" belongs to a "JOIN" or an "ON CONFLICT" clause.
3031+ *
3032+ * See: https://www.sqlite.org/lang_insert.html
3033+ */
30263034 $ fragment .= ' FROM ( ' . $ this ->translate ( $ values ) . ') WHERE true ' ;
30273035
30283036 return $ fragment ;
You can’t perform that action at this time.
0 commit comments