Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions coverage/sqldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ def update(

# Get contexts data.
with con.execute("select context from context") as cur:
contexts = [context for (context,) in cur]
contexts = cur.fetchall()

# Get arc data.
with con.execute(
Expand Down Expand Up @@ -743,14 +743,14 @@ def update(
# Create all file and context rows in the DB.
con.executemany_void(
"insert or ignore into file (path) values (?)",
((file,) for file in files.values()),
[(file,) for file in files.values()],
)
with con.execute("select id, path from file") as cur:
file_ids = {path: id for id, path in cur}
self._file_map.update(file_ids)
con.executemany_void(
"insert or ignore into context (context) values (?)",
((context,) for context in contexts),
contexts,
)
with con.execute("select id, context from context") as cur:
context_ids = {context: id for id, context in cur}
Expand Down Expand Up @@ -778,10 +778,10 @@ def update(
if arcs:
self._choose_lines_or_arcs(arcs=True)

arc_rows = (
arc_rows = [
(file_ids[file], context_ids[context], fromno, tono)
for file, context, fromno, tono in arcs
)
]

# Write the combined data.
con.executemany_void(
Expand Down Expand Up @@ -813,7 +813,7 @@ def update(

con.executemany_void(
"insert or ignore into tracer (file_id, tracer) values (?, ?)",
((file_ids[filename], tracer) for filename, tracer in tracer_map.items()),
[(file_ids[filename], tracer) for filename, tracer in tracer_map.items()],
)

if not self._no_disk:
Expand Down
3 changes: 1 addition & 2 deletions coverage/sqlitedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,8 @@ def _executemany(self, sql: str, data: list[Any]) -> sqlite3.Cursor:
# https://github.com/nedbat/coveragepy/issues/1010
return self.con.executemany(sql, data)

def executemany_void(self, sql: str, data: Iterable[Any]) -> None:
def executemany_void(self, sql: str, data: list[Any]) -> None:
"""Same as :meth:`python:sqlite3.Connection.executemany` when you don't need the cursor."""
data = list(data)
if data:
self._executemany(sql, data).close()

Expand Down
Loading