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
+
When an error is thrown in the conflict handler or when any other value is returned from the handler,
255
+
applying the changeset is aborted and the database is rolled back.
256
+
257
+
**Default**: A function that returns `SQLITE_CHANGESET_ABORT`.
241
258
* Returns: {boolean} Whether the changeset was applied succesfully without being aborted.
242
259
243
260
An exception is thrown if the database is not
@@ -496,9 +513,42 @@ An object containing commonly used constants for SQLite operations.
496
513
497
514
The following constants are exported by the `sqlite.constants` object.
498
515
499
-
#### Conflict-resolution constants
516
+
#### Conflict resolution constants
517
+
518
+
One of the following constants is available as an argument to the `onConflict`
519
+
conflict resolution handler passed to [`database.applyChangeset()`][]. See also
520
+
[Constants Passed To The Conflict Handler][] in the SQLite documentation.
521
+
522
+
<table>
523
+
<tr>
524
+
<th>Constant</th>
525
+
<th>Description</th>
526
+
</tr>
527
+
<tr>
528
+
<td><code>SQLITE_CHANGESET_DATA</code></td>
529
+
<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>
530
+
</tr>
531
+
<tr>
532
+
<td><code>SQLITE_CHANGESET_NOTFOUND</code></td>
533
+
<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>
534
+
</tr>
535
+
<tr>
536
+
<td><code>SQLITE_CHANGESET_CONFLICT</code></td>
537
+
<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>
538
+
</tr>
539
+
<tr>
540
+
<td><code>SQLITE_CHANGESET_CONSTRAINT</code></td>
541
+
<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>
546
+
</tr>
547
+
</table>
500
548
501
-
The following constants are meant for use with [`database.applyChangeset()`](#databaseapplychangesetchangeset-options).
549
+
One of the following constants must be returned from the `onConflict` conflict
550
+
resolution handler passed to [`database.applyChangeset()`][]. See also
551
+
[Constants Returned From The Conflict Handler][] in the SQLite documentation.
502
552
503
553
<table>
504
554
<tr>
@@ -511,7 +561,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>
515
565
</tr>
516
566
<tr>
517
567
<td><code>SQLITE_CHANGESET_ABORT</code></td>
@@ -520,11 +570,14 @@ The following constants are meant for use with [`database.applyChangeset()`](#da
520
570
</table>
521
571
522
572
[Changesets and Patchsets]: https://www.sqlite.org/sessionintro.html#changesets_and_patchsets
573
+
[Constants Passed To The Conflict Handler]: https://www.sqlite.org/session/c_changeset_conflict.html
574
+
[Constants Returned From The Conflict Handler]: https://www.sqlite.org/session/c_changeset_abort.html
0 commit comments