[sqlite] don't call abspath is :memory: is given

else you ends up with a :memory: file in your working directory.

Closes #2777197

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changesetaabdf2b17fe0
branchdefault
phasedraft
hiddenyes
parent revision#cbaf22060a41 stop dropping tzinfo when specified. Closes #1485893
child revision#cb3ff5d1c2e3 make sqlite tz datetime aware
files modified by this revision
logilab/database/sqlite.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1448359002 -3600
# Tue Nov 24 10:56:42 2015 +0100
# Node ID aabdf2b17fe01d68dea2de1d529c0ce1f4931f76
# Parent cbaf22060a41754bd8bf3d2ce28e823eba4ce5d7
[sqlite] don't call abspath is :memory: is given

else you ends up with a :memory: file in your working directory.

Closes #2777197

diff --git a/logilab/database/sqlite.py b/logilab/database/sqlite.py
@@ -195,11 +195,13 @@
1              def __getattr__(self, attrname):
2                  return getattr(self._cnx, attrname)
3 
4          # abspath so we can change cwd without breaking further queries on the
5          # database
6 -        cnx = sqlite.connect(abspath(database),
7 +        if database != ':memory:':
8 +            database = abspath(database)
9 +        cnx = sqlite.connect(database,
10                               detect_types=sqlite.PARSE_DECLTYPES, check_same_thread=False)
11          return self._wrap_if_needed(Sqlite3CnxWrapper(cnx))
12 
13      def _transformation_callback(self, description, encoding='utf-8', binarywrap=None):
14          def _transform(value):