You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`SQLITE_CHANGESET_REPLACE`: Replace existing values with conflicting changes (only valid with
251
+
`SQLITE_CHANGESET_DATA` or `SQLITE_CHANGESET_CONFLICT` conflicts).
252
+
*`SQLITE_CHANGESET_ABORT`: Abort on conflict and roll back the database.
253
+
254
+
**Default**: A function that returns `SQLITE_CHANGESET_ABORT`.
241
255
* Returns: {boolean} Whether the changeset was applied succesfully without being aborted.
242
256
243
257
An exception is thrown if the database is not
@@ -496,9 +510,38 @@ An object containing commonly used constants for SQLite operations.
496
510
497
511
The following constants are exported by the `sqlite.constants` object.
498
512
499
-
#### Conflict-resolution constants
513
+
#### Conflict resolution constants
514
+
515
+
One of the following constants is available as an argument to the `onConflict` conflict resolution handler passed to [`database.applyChangeset()`](#databaseapplychangesetchangeset-options)). See also [Constants Passed To The Conflict Handler](https://www.sqlite.org/session/c_changeset_conflict.html) in the SQLite documentation.
516
+
517
+
<table>
518
+
<tr>
519
+
<th>Constant</th>
520
+
<th>Description</th>
521
+
</tr>
522
+
<tr>
523
+
<td><code>SQLITE_CHANGESET_DATA</code></td>
524
+
<td>The conflict handler is invoked with this constant when processing a DELETE or UPDATE change if a row with the required PRIMARY KEY fields is present in the database, but one or more other (non primary-key) fields modified by the update do not contain the expected "before" values.</td>
525
+
</tr>
526
+
<tr>
527
+
<td><code>SQLITE_CHANGESET_NOTFOUND</code></td>
528
+
<td>The conflict handler is invoked with this constant when processing a DELETE or UPDATE change if a row with the required PRIMARY KEY fields is not present in the database.</td>
529
+
</tr>
530
+
<tr>
531
+
<td><code>SQLITE_CHANGESET_CONFLICT</code></td>
532
+
<td>This constant is passed to the conflict handler while processing an INSERT change if the operation would result in duplicate primary key values.</td>
533
+
</tr>
534
+
<tr>
535
+
<td><code>SQLITE_CHANGESET_CONSTRAINT</code></td>
536
+
<td>If foreign key handling is enabled, and applying a changeset leaves the database in a state containing foreign key violations, the conflict handler is invoked with this constant exactly once before the changeset is committed. If the conflict handler returns SQLITE_CHANGESET_OMIT, the changes, including those that caused the foreign key constraint violation, are committed. Or, if it returns SQLITE_CHANGESET_ABORT, the changeset is rolled back.</td>
<td>If any other constraint violation occurs while applying a change (i.e. a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is invoked with this constant.</td>
541
+
</tr>
542
+
</table>
500
543
501
-
The following constants are meant for use with [`database.applyChangeset()`](#databaseapplychangesetchangeset-options).
544
+
One of the following constants must be returned from the `onConflict` conflict resolution handler passed to [`database.applyChangeset()`](#databaseapplychangesetchangeset-options). See also [Constants Returned From The Conflict Handler](https://www.sqlite.org/session/c_changeset_abort.html) in the SQLite documentation.
502
545
503
546
<table>
504
547
<tr>
@@ -511,7 +554,7 @@ The following constants are meant for use with [`database.applyChangeset()`](#da
<td>Conflicting changes replace existing values. Note that this value can only be returned when the type of conflict is either `SQLITE_CHANGESET_DATA` or `SQLITE_CHANGESET_CONFLICT`.</td>
0 commit comments