empty lists are None not '', fixes #102
This commit is contained in:
parent
b899768130
commit
d876768771
3 changed files with 14 additions and 3 deletions
|
@ -181,7 +181,7 @@ class Item(db.Model):
|
||||||
value = str(value)
|
value = str(value)
|
||||||
value = ox.sort_string(value).lower()
|
value = ox.sort_string(value).lower()
|
||||||
elif isinstance(value, list): #empty list
|
elif isinstance(value, list): #empty list
|
||||||
value = ''
|
value = None
|
||||||
if getattr(s, key['id']) != value:
|
if getattr(s, key['id']) != value:
|
||||||
setattr(s, key['id'], value)
|
setattr(s, key['id'], value)
|
||||||
update = True
|
update = True
|
||||||
|
|
|
@ -82,4 +82,4 @@ USER_AGENT = 'OpenMediaLibrary/%s' % VERSION
|
||||||
|
|
||||||
DEBUG_HTTP = server.get('debug_http', False)
|
DEBUG_HTTP = server.get('debug_http', False)
|
||||||
|
|
||||||
DB_VERSION = 0
|
DB_VERSION = 1
|
||||||
|
|
|
@ -18,6 +18,7 @@ import ox
|
||||||
from oxtornado import actions
|
from oxtornado import actions
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
|
import db
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -277,7 +278,8 @@ class Update(Thread):
|
||||||
db_version = settings.server.get('db_version', 0)
|
db_version = settings.server.get('db_version', 0)
|
||||||
if db_version < settings.DB_VERSION:
|
if db_version < settings.DB_VERSION:
|
||||||
self.status('Migrating database...')
|
self.status('Migrating database...')
|
||||||
time.sleep(30)
|
if db_version < 1:
|
||||||
|
db_version = migrate_1()
|
||||||
settings.server['db_version'] = settings.DB_VERSION
|
settings.server['db_version'] = settings.DB_VERSION
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -288,3 +290,12 @@ class Update(Thread):
|
||||||
return
|
return
|
||||||
self.status('Relaunching...', True)
|
self.status('Relaunching...', True)
|
||||||
restart_oml()
|
restart_oml()
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_1():
|
||||||
|
with db.session() as session:
|
||||||
|
import item.models
|
||||||
|
for s in item.models.Sort.query.filter_by(author=''):
|
||||||
|
s.item.update_sort()
|
||||||
|
session.commit()
|
||||||
|
return 1
|
||||||
|
|
Loading…
Reference in a new issue