From 54bae0298d40502ebf43055ac9a6f28338633683 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 23 Oct 2018 14:07:18 +0200 Subject: CoverageSqliteData._file_id: fall back to SELECT Fixes https://github.com/nedbat/coveragepy/issues/702 --- coverage/sqldata.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'coverage/sqldata.py') diff --git a/coverage/sqldata.py b/coverage/sqldata.py index 8bfb04be..d93bc062 100644 --- a/coverage/sqldata.py +++ b/coverage/sqldata.py @@ -181,13 +181,13 @@ class CoverageSqliteData(SimpleReprMixin): def _file_id(self, filename, add=False): """Get the file id for `filename`. - If filename is not in the database yet, add if it `add` is True. + If filename is not in the database yet, add it if `add` is True. If `add` is not True, return None. """ if filename not in self._file_map: if add: with self._connect() as con: - cur = con.execute("insert into file (path) values (?)", (filename,)) + cur = con.execute("insert or replace into file (path) values (?)", (filename,)) self._file_map[filename] = cur.lastrowid return self._file_map.get(filename) -- cgit v1.2.1