mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-26 19:04:32 +02:00
Compare commits
2 commits
main
...
empty-list
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8daea7f126 |
||
|
|
ace7a97b2b |
2 changed files with 13 additions and 1 deletions
|
|
@ -977,7 +977,10 @@ class Table(Queryable):
|
||||||
# we need to adjust the batch_size down if we have too many cols
|
# we need to adjust the batch_size down if we have too many cols
|
||||||
records = iter(records)
|
records = iter(records)
|
||||||
# Peek at first record to count its columns:
|
# Peek at first record to count its columns:
|
||||||
|
try:
|
||||||
first_record = next(records)
|
first_record = next(records)
|
||||||
|
except StopIteration:
|
||||||
|
return self # It was an empty list
|
||||||
num_columns = len(first_record.keys())
|
num_columns = len(first_record.keys())
|
||||||
assert (
|
assert (
|
||||||
num_columns <= SQLITE_MAX_VARS
|
num_columns <= SQLITE_MAX_VARS
|
||||||
|
|
|
||||||
|
|
@ -789,3 +789,12 @@ def test_drop_view(fresh_db):
|
||||||
assert ["foo_view"] == fresh_db.view_names()
|
assert ["foo_view"] == fresh_db.view_names()
|
||||||
assert None is fresh_db["foo_view"].drop()
|
assert None is fresh_db["foo_view"].drop()
|
||||||
assert [] == fresh_db.view_names()
|
assert [] == fresh_db.view_names()
|
||||||
|
|
||||||
|
|
||||||
|
def test_insert_upsert_all_empty_list(fresh_db):
|
||||||
|
fresh_db["t"].insert({"foo": 1})
|
||||||
|
assert 1 == fresh_db["t"].count
|
||||||
|
fresh_db["t"].insert_all([])
|
||||||
|
assert 1 == fresh_db["t"].count
|
||||||
|
fresh_db["t"].upsert_all([])
|
||||||
|
assert 1 == fresh_db["t"].count
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue