This commit is contained in:
yumoqing 2019-08-30 21:03:26 +08:00
parent 74c3b0dc29
commit f7ac6112ec

View File

@ -56,15 +56,17 @@ class CRUD(object):
""" """
fields information fields information
""" """
fields = await self.primaryKey() pkdata = await self.primaryKey()
pks = [ i.field_name for i in fields ] pks = [ i.field_name for i in pkdata ]
data = await self.pool.getTableFields(self.dbname,self.tablename) data = await self.pool.getTableFields(self.dbname,self.tablename)
[ d.update({'primarykey':True}) for d in data if d.name in pks ] for d in data:
if d.name in pks:
d.update({'primarykey':True})
data = self.oa.execute(self.dbname+'_'+self.tablename,'tableInfo',data) data = self.oa.execute(self.dbname+'_'+self.tablename,'tableInfo',data)
return data return data
async def fromStr(self,data): async def fromStr(self,data):
fields = await getTableFields(self.dbname,self.tablename) fields = await self.pool.getTableFields(self.dbname,self.tablename)
ret = {} ret = {}
for k in data: for k in data:
v = None if data[k] == '' else data[k] v = None if data[k] == '' else data[k]
@ -77,7 +79,7 @@ class CRUD(object):
return ret return ret
async def toStr(self,data): async def toStr(self,data):
fields = await getTableFields(self.dbname,self.tablename) fields = await self.pool.getTableFields(self.dbname,self.tablename)
ret = {} ret = {}
for k in data: for k in data:
for f in fields: for f in fields: