mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-09 18:14:09 +02:00
Use ON CONFLICT for upsert, refs #652
* New upsert implementation, refs #652 * supports_strict now caches on self._supports_strict PR: https://github.com/simonw/sqlite-utils/pull/653
This commit is contained in:
parent
72f6c820f6
commit
8e7d018fa2
7 changed files with 209 additions and 110 deletions
|
|
@ -1,9 +1,12 @@
|
|||
from sqlite_utils.db import PrimaryKeyRequired
|
||||
from sqlite_utils import Database
|
||||
import pytest
|
||||
|
||||
|
||||
def test_upsert(fresh_db):
|
||||
table = fresh_db["table"]
|
||||
@pytest.mark.parametrize("use_old_upsert", (False, True))
|
||||
def test_upsert(use_old_upsert):
|
||||
db = Database(memory=True, use_old_upsert=use_old_upsert)
|
||||
table = db["table"]
|
||||
table.insert({"id": 1, "name": "Cleo"}, pk="id")
|
||||
table.upsert({"id": 1, "age": 5}, pk="id", alter=True)
|
||||
assert list(table.rows) == [{"id": 1, "name": "Cleo", "age": 5}]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue