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
247
+
`SQLITE_CHANGESET_DATA` or `SQLITE_CHANGESET_CONFLICT` conflicts).
248
+
*`SQLITE_CHANGESET_ABORT`: Abort on conflict and roll back the database.
249
+
250
+
When an error is thrown in the conflict handler or when any other value is returned from the handler,
251
+
applying the changeset is aborted and the database is rolled back.
252
+
253
+
**Default**: A function that returns `SQLITE_CHANGESET_ABORT`.
237
254
* Returns: {boolean} Whether the changeset was applied succesfully without being aborted.
238
255
239
256
An exception is thrown if the database is not
@@ -486,9 +503,42 @@ An object containing commonly used constants for SQLite operations.
486
503
487
504
The following constants are exported by the `sqlite.constants` object.
488
505
489
-
#### Conflict-resolution constants
506
+
#### Conflict resolution constants
507
+
508
+
One of the following constants is available as an argument to the `onConflict`
509
+
conflict resolution handler passed to [`database.applyChangeset()`][]. See also
510
+
[Constants Passed To The Conflict Handler][] in the SQLite documentation.
511
+
512
+
<table>
513
+
<tr>
514
+
<th>Constant</th>
515
+
<th>Description</th>
516
+
</tr>
517
+
<tr>
518
+
<td><code>SQLITE_CHANGESET_DATA</code></td>
519
+
<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>
520
+
</tr>
521
+
<tr>
522
+
<td><code>SQLITE_CHANGESET_NOTFOUND</code></td>
523
+
<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>
524
+
</tr>
525
+
<tr>
526
+
<td><code>SQLITE_CHANGESET_CONFLICT</code></td>
527
+
<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>
528
+
</tr>
529
+
<tr>
530
+
<td><code>SQLITE_CHANGESET_CONSTRAINT</code></td>
531
+
<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 <code>SQLITE_CHANGESET_OMIT</code>, the changes, including those that caused the foreign key constraint violation, are committed. Or, if it returns <code>SQLITE_CHANGESET_ABORT</code>, 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>
536
+
</tr>
537
+
</table>
490
538
491
-
The following constants are meant for use with [`database.applyChangeset()`](#databaseapplychangesetchangeset-options).
539
+
One of the following constants must be returned from the `onConflict` conflict
540
+
resolution handler passed to [`database.applyChangeset()`][]. See also
541
+
[Constants Returned From The Conflict Handler][] in the SQLite documentation.
492
542
493
543
<table>
494
544
<tr>
@@ -501,7 +551,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 <code>SQLITE_CHANGESET_DATA</code> or <code>SQLITE_CHANGESET_CONFLICT</code>.</td>
505
555
</tr>
506
556
<tr>
507
557
<td><code>SQLITE_CHANGESET_ABORT</code></td>
@@ -510,11 +560,14 @@ The following constants are meant for use with [`database.applyChangeset()`](#da
510
560
</table>
511
561
512
562
[Changesets and Patchsets]: https://www.sqlite.org/sessionintro.html#changesets_and_patchsets
563
+
[Constants Passed To The Conflict Handler]: https://www.sqlite.org/session/c_changeset_conflict.html
564
+
[Constants Returned From The Conflict Handler]: https://www.sqlite.org/session/c_changeset_abort.html
0 commit comments