use sqlalchemy.sql.expression.text
This commit is contained in:
parent
386284693d
commit
805486e8fc
2 changed files with 10 additions and 6 deletions
|
@ -6,6 +6,7 @@ from datetime import datetime
|
|||
import json
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql.expression import text
|
||||
|
||||
from utils import datetime2ts, ts2datetime
|
||||
from websocket import trigger_event
|
||||
|
@ -125,13 +126,13 @@ class Changelog(db.Model):
|
|||
break
|
||||
return False
|
||||
if trigger:
|
||||
trigger_event('change', {});
|
||||
trigger_event('change', {})
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def apply_change(cls, user, change, trigger=True):
|
||||
revision, timestamp, data = change
|
||||
last = cls.query.filter_by(user_id=user.id).order_by('-revision').first()
|
||||
last = cls.query.filter_by(user_id=user.id).order_by(text('-revision')).first()
|
||||
next_revision = last.revision + 1 if last else 0
|
||||
if revision >= next_revision:
|
||||
c = cls()
|
||||
|
@ -146,7 +147,7 @@ class Changelog(db.Model):
|
|||
state.db.session.add(c)
|
||||
state.db.session.commit()
|
||||
if trigger:
|
||||
trigger_event('change', {});
|
||||
trigger_event('change', {})
|
||||
return True
|
||||
else:
|
||||
logger.debug('could not apply change')
|
||||
|
|
|
@ -7,7 +7,9 @@ import json
|
|||
import os
|
||||
import tarfile
|
||||
from threading import Thread
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -16,6 +18,7 @@ import time
|
|||
import OpenSSL.crypto
|
||||
import ox
|
||||
from oxtornado import actions
|
||||
from sqlalchemy.sql.expression import text
|
||||
|
||||
import settings
|
||||
import utils
|
||||
|
@ -27,7 +30,7 @@ import logging
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
ENCODING='base64'
|
||||
ENCODING = 'base64'
|
||||
|
||||
def verify(release):
|
||||
verified = False
|
||||
|
@ -541,7 +544,7 @@ def migrate_11():
|
|||
import utils
|
||||
for u in User.query.filter_by(peered=True):
|
||||
peer = utils.get_peer(u.id)
|
||||
last = Changelog.query.filter_by(user_id=u.id).order_by('-revision').first()
|
||||
last = Changelog.query.filter_by(user_id=u.id).order_by(text('-revision')).first()
|
||||
if last:
|
||||
peer.info['revision'] = last.revision
|
||||
listorder = []
|
||||
|
|
Loading…
Reference in a new issue