bugfix
This commit is contained in:
parent
bcf6a4ac2a
commit
34121108d1
31
sqlor/sor.py
31
sqlor/sor.py
@ -14,7 +14,7 @@ from appPublic.unicoding import uDict
|
||||
from appPublic.myTE import MyTemplateEngine
|
||||
from appPublic.objectAction import ObjectAction
|
||||
from appPublic.argsConvert import ArgsConvert,ConditionConvert
|
||||
from appPublic.registerfunction import RegisterFunction
|
||||
from appPublic.registerfunction import RegisterCoroutine
|
||||
from appPublic.log import info
|
||||
from .filter import DBFilter
|
||||
|
||||
@ -607,16 +607,11 @@ class SQLor(object):
|
||||
fns = ','.join(fields)
|
||||
vfns = ','.join(['${%s}$' % n for n in fields ])
|
||||
sql = 'insert into %s.%s (%s) values (%s)' % (self.dbname, tablename,fns,vfns)
|
||||
rf = RegisterFunction()
|
||||
rf = RegisterCoroutine()
|
||||
rfname = f'{self.dbname}:{tablename}:c:before'
|
||||
info(f'{rfname=}')
|
||||
func = rf.get(rfname)
|
||||
if func:
|
||||
ns = func(ns)
|
||||
ns = await rf.exe(rfname, ns)
|
||||
r = await self.runSQL({'sql_string':sql},ns,None)
|
||||
func = rf.get(f'{self.dbname}:{tablename}:c:after')
|
||||
if func:
|
||||
ns = func(ns)
|
||||
await rf.exe(f'{self.dbname}:{tablename}:c:after', ns)
|
||||
return r
|
||||
|
||||
async def R(self,tablename,ns,filters=None):
|
||||
@ -662,14 +657,12 @@ class SQLor(object):
|
||||
u_str = ','.join(u)
|
||||
sql = 'update %s.%s set %s where %s' % (self.dbname, tablename,
|
||||
u_str,c_str)
|
||||
rf = RegisterFunction()
|
||||
func = rf.get(f'{self.dbname}:{tablename}:u:before')
|
||||
rf = RegisterCoroutine()
|
||||
ns = await rf.exe(f'{self.dbname}:{tablename}:u:before',ns)
|
||||
if func:
|
||||
ns = func(ns)
|
||||
r = await self.runSQL({'sql_string':sql},ns,None)
|
||||
func = rf.get(f'{self.dbname}:{tablename}:u:after')
|
||||
if func:
|
||||
ns = func(ns)
|
||||
await rf.exe(f'{self.dbname}:{tablename}:u:after',ns)
|
||||
return r
|
||||
|
||||
async def D(self,tablename,ns):
|
||||
@ -679,13 +672,9 @@ class SQLor(object):
|
||||
c = [ '%s = ${%s}$' % (i,i) for i in condi ]
|
||||
c_str = ' and '.join(c)
|
||||
sql = 'delete from %s.%s where %s' % (self.dbname, tablename,c_str)
|
||||
rf = RegisterFunction()
|
||||
func = rf.get(f'{self.dbname}:{tablename}:d:before')
|
||||
if func:
|
||||
ns = func(ns)
|
||||
rf = RegisterCoroutine()
|
||||
ns = await rf.exe(f'{self.dbname}:{tablename}:d:before', ns)
|
||||
r = await self.runSQL({'sql_string':sql},ns,None)
|
||||
func = rf.get(f'{self.dbname}:{tablename}:d:after')
|
||||
if func:
|
||||
ns = func(ns)
|
||||
ns = await rf.get(f'{self.dbname}:{tablename}:d:after', ns)
|
||||
return r
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user