1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-02-27 09:57:46 +03:00

Removed ceil creating function on sqlite

This commit is contained in:
Adolfo Gómez García 2023-04-21 00:46:06 +02:00
parent 9b4d1139d1
commit c8982cf677
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
4 changed files with 1 additions and 14 deletions

View File

@ -95,5 +95,4 @@ def extend_sqlite(connection=None, **kwargs):
cursor.execute('PRAGMA journal_mode=WAL')
connection.connection.create_function("MIN", 2, min)
connection.connection.create_function("MAX", 2, max)
connection.connection.create_function("CEIL", 1, math.ceil)

View File

@ -36,8 +36,6 @@ import logging
from django.db import models
from .util import getSqlFnc
logger = logging.getLogger(__name__)
@ -117,7 +115,7 @@ class StatsCounters(models.Model):
max_intervals = max(min(max_intervals, count), 2)
interval = int(to - since) / max_intervals
floor = getSqlFnc('FLOOR')
floor = 'FLOOR'
if interval > 0:
q = q.extra( # nosec: SQL injection is not possible here
select={

View File

@ -37,7 +37,6 @@ import logging
from django.db import models
from .util import getSqlFnc
from .stats_counters import StatsCounters
if typing.TYPE_CHECKING:

View File

@ -85,12 +85,3 @@ def getSqlDatetime() -> datetime:
def getSqlDatetimeAsUnix() -> int:
return int(mktime(getSqlDatetime().timetuple()))
def getSqlFnc(fncName: str) -> str:
"""
Convert different sql functions for different platforms
"""
if connection.vendor == 'microsoft':
return {'CEIL': 'CEILING'}.get(fncName, fncName)
return fncName