bugfix
This commit is contained in:
parent
023999cf0d
commit
bcf6a4ac2a
36
sqlor/sor.py
36
sqlor/sor.py
@ -14,6 +14,8 @@ from appPublic.unicoding import uDict
|
|||||||
from appPublic.myTE import MyTemplateEngine
|
from appPublic.myTE import MyTemplateEngine
|
||||||
from appPublic.objectAction import ObjectAction
|
from appPublic.objectAction import ObjectAction
|
||||||
from appPublic.argsConvert import ArgsConvert,ConditionConvert
|
from appPublic.argsConvert import ArgsConvert,ConditionConvert
|
||||||
|
from appPublic.registerfunction import RegisterFunction
|
||||||
|
from appPublic.log import info
|
||||||
from .filter import DBFilter
|
from .filter import DBFilter
|
||||||
|
|
||||||
def db_type_2_py_type(o):
|
def db_type_2_py_type(o):
|
||||||
@ -605,7 +607,17 @@ class SQLor(object):
|
|||||||
fns = ','.join(fields)
|
fns = ','.join(fields)
|
||||||
vfns = ','.join(['${%s}$' % n for n in fields ])
|
vfns = ','.join(['${%s}$' % n for n in fields ])
|
||||||
sql = 'insert into %s.%s (%s) values (%s)' % (self.dbname, tablename,fns,vfns)
|
sql = 'insert into %s.%s (%s) values (%s)' % (self.dbname, tablename,fns,vfns)
|
||||||
await self.runSQL({'sql_string':sql},ns,None)
|
rf = RegisterFunction()
|
||||||
|
rfname = f'{self.dbname}:{tablename}:c:before'
|
||||||
|
info(f'{rfname=}')
|
||||||
|
func = rf.get(rfname)
|
||||||
|
if func:
|
||||||
|
ns = func(ns)
|
||||||
|
r = await self.runSQL({'sql_string':sql},ns,None)
|
||||||
|
func = rf.get(f'{self.dbname}:{tablename}:c:after')
|
||||||
|
if func:
|
||||||
|
ns = func(ns)
|
||||||
|
return r
|
||||||
|
|
||||||
async def R(self,tablename,ns,filters=None):
|
async def R(self,tablename,ns,filters=None):
|
||||||
desc = await self.I(tablename)
|
desc = await self.I(tablename)
|
||||||
@ -650,8 +662,15 @@ class SQLor(object):
|
|||||||
u_str = ','.join(u)
|
u_str = ','.join(u)
|
||||||
sql = 'update %s.%s set %s where %s' % (self.dbname, tablename,
|
sql = 'update %s.%s set %s where %s' % (self.dbname, tablename,
|
||||||
u_str,c_str)
|
u_str,c_str)
|
||||||
await self.runSQL({'sql_string':sql},ns,None)
|
rf = RegisterFunction()
|
||||||
pass
|
func = rf.get(f'{self.dbname}:{tablename}:u:before')
|
||||||
|
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)
|
||||||
|
return r
|
||||||
|
|
||||||
async def D(self,tablename,ns):
|
async def D(self,tablename,ns):
|
||||||
desc = await self.I(tablename)
|
desc = await self.I(tablename)
|
||||||
@ -660,6 +679,13 @@ class SQLor(object):
|
|||||||
c = [ '%s = ${%s}$' % (i,i) for i in condi ]
|
c = [ '%s = ${%s}$' % (i,i) for i in condi ]
|
||||||
c_str = ' and '.join(c)
|
c_str = ' and '.join(c)
|
||||||
sql = 'delete from %s.%s where %s' % (self.dbname, tablename,c_str)
|
sql = 'delete from %s.%s where %s' % (self.dbname, tablename,c_str)
|
||||||
await self.runSQL({'sql_string':sql},ns,None)
|
rf = RegisterFunction()
|
||||||
|
func = rf.get(f'{self.dbname}:{tablename}:d:before')
|
||||||
|
if func:
|
||||||
|
ns = func(ns)
|
||||||
|
r = await self.runSQL({'sql_string':sql},ns,None)
|
||||||
|
func = rf.get(f'{self.dbname}:{tablename}:d:after')
|
||||||
|
if func:
|
||||||
|
ns = func(ns)
|
||||||
|
return r
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user