changeset 2507:4c45df43ea44

core (memory/sqlite): renamed column for files from hash to file_hash: the version has not been changed to avoid too creating update for such a small change. Even if generally a database change means a version change, this one has not be wide spreaded, and it will be updated automatically for dev version. A manual "drop table files" using sqlite3 shell might clean things up though. The reason of the column name change is that hash is named file_hash in code (because "hash" is a reserved word), and using the same name simplify data manipulation.
author Goffi <goffi@goffi.org>
date Fri, 02 Mar 2018 17:36:43 +0100
parents 516bf5309517
children 4e5cc45e2be7
files src/memory/sqlite.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/memory/sqlite.py	Thu Mar 01 09:04:36 2018 +0100
+++ b/src/memory/sqlite.py	Fri Mar 02 17:36:43 2018 +0100
@@ -82,7 +82,7 @@
                               ('files',           (("id TEXT NOT NULL", "version TEXT NOT NULL", "parent TEXT NOT NULL",
                                                     "type TEXT CHECK(type in ('{file}', '{directory}')) NOT NULL DEFAULT '{file}'".format(
                                                         file=C.FILE_TYPE_FILE, directory=C.FILE_TYPE_DIRECTORY),
-                                                    "hash TEXT", "hash_algo TEXT", "name TEXT NOT NULL", "size INTEGER",
+                                                    "file_hash TEXT", "hash_algo TEXT", "name TEXT NOT NULL", "size INTEGER",
                                                     "namespace TEXT", "mime_type TEXT",
                                                     "created DATETIME NOT NULL", "modified DATETIME",
                                                     "owner TEXT", "access TEXT", "extra TEXT", "profile_id INTEGER"),
@@ -101,7 +101,7 @@
         5:         {'create': {'files': (("id TEXT NOT NULL", "version TEXT NOT NULL", "parent TEXT NOT NULL",
                                           "type TEXT CHECK(type in ('{file}', '{directory}')) NOT NULL DEFAULT '{file}'".format(
                                               file=C.FILE_TYPE_FILE, directory=C.FILE_TYPE_DIRECTORY),
-                                          "hash TEXT", "hash_algo TEXT", "name TEXT NOT NULL", "size INTEGER",
+                                          "file_hash TEXT", "hash_algo TEXT", "name TEXT NOT NULL", "size INTEGER",
                                           "namespace TEXT", "mime_type TEXT",
                                           "created DATETIME NOT NULL", "modified DATETIME",
                                           "owner TEXT", "access TEXT", "extra TEXT", "profile_id INTEGER"),
@@ -696,7 +696,7 @@
         if unique:
             query_parts.append('DISTINCT')
         if projection is None:
-            projection = ['id', 'version', 'parent', 'type', 'hash', 'hash_algo', 'name',
+            projection = ['id', 'version', 'parent', 'type', 'file_hash', 'hash_algo', 'name',
                           'size', 'namespace', 'mime_type', 'created', 'modified', 'owner',
                           'access', 'extra']
         query_parts.append(','.join(projection))
@@ -717,7 +717,7 @@
             filters.append(u'type=?')
             args.append(type_)
         if file_hash is not None:
-            filters.append(u'hash=?')
+            filters.append(u'file_hash=?')
             args.append(file_hash)
         if hash_algo is not None:
             filters.append(u'hash_algo=?')
@@ -785,7 +785,7 @@
         """
         if extra is not None:
          assert isinstance(extra, dict)
-        query = ('INSERT INTO files(id, version, parent, type, hash, hash_algo, name, size, namespace, '
+        query = ('INSERT INTO files(id, version, parent, type, file_hash, hash_algo, name, size, namespace, '
                  'mime_type, created, modified, owner, access, extra, profile_id) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)')
         d = self.dbpool.runQuery(query, (file_id, version.strip(), parent, type_,
                                          file_hash, hash_algo,