Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoverageSqliteData._file_id: use "insert or replace" #723

Merged
merged 1 commit into from
Apr 8, 2019
Merged
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
4 changes: 2 additions & 2 deletions coverage/sqldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ def dump(self): # pragma: debugging
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,))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this fix relate to #760?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've made the link.. I guess it can help, but can only say it for #702 (comment) really, although I've not tested the "insert or replace" attempt with that one.

self._file_map[filename] = cur.lastrowid
return self._file_map.get(filename)

Expand Down