[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>
changesetbca353bb8876
branchdefault
phasepublic
hiddenno
parent revision#80a92a6d8b49 [mysql] don't encode strings on python3
child revision#0f8c03d2620a stop dropping tzinfo when specified. Closes #1485893, #ed52024eb301 merge packaging fixes
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 bca353bb887696fc321b734bf2aa125b802b157b
# Parent 80a92a6d8b49c6209c6ff3b8d7a565ea747256ed
[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):