Message375910
The full workaround is in https://github.com/WolfgangFahl/DgraphAndWeaviateTest/commit/f1a58d75f459bf78db327acddaf01d5cf64eb7d4
def testBindingError(self):
'''
test list of Records with incomplete record leading to
"You did not supply a value for binding 2"
see https://bugs.python.org/issue41638
'''
listOfRecords=[{'name':'Pikachu', 'type':'Electric'},{'name':'Raichu' }]
for executeMany in [True,False]:
try:
self.checkListOfRecords(listOfRecords,'Pokemon','name',executeMany=executeMany)
self.fail("There should be an exception")
except Exception as ex:
if self.debug:
print(str(ex))
self.assertTrue('no value supplied for column' in str(ex))
Giving the error messages:
INSERT INTO Pokemon (name,type) values (:name,:type)
failed: no value supplied for column 'type'
in mode "executeMany"
INSERT INTO Pokemon (name,type) values (:name,:type)
failed: no value supplied for column 'type'
record #2={'name': 'Raichu'}
if executeMany is not used and errorDebug is on
The wrapper code is:
def store(self,listOfRecords,entityInfo,executeMany=False):
'''
store the given list of records based on the given entityInfo
Args:
listOfRecords(list): the list of Dicts to be stored
entityInfo(EntityInfo): the meta data to be used for storing
'''
insertCmd=entityInfo.insertCmd
try:
if executeMany:
self.c.executemany(insertCmd,listOfRecords)
else:
index=0
for record in listOfRecords:
index+=1
self.c.execute(insertCmd,record)
self.c.commit()
except sqlite3.ProgrammingError as pe:
msg=pe.args[0]
if "You did not supply a value for binding" in msg:
columnIndex=int(re.findall(r'\d+',msg)[0])
columnName=list(entityInfo.typeMap.keys())[columnIndex-1]
debugInfo=""
if not executeMany:
if self.errorDebug:
debugInfo="\nrecord #%d=%s" % (index,repr(record))
raise Exception("%s\nfailed: no value supplied for column '%s'%s" % (insertCmd,columnName,debugInfo))
else:
raise pe |
|
Date |
User |
Action |
Args |
2020-08-26 06:51:45 | WolfgangFahl | set | recipients:
+ WolfgangFahl |
2020-08-26 06:51:45 | WolfgangFahl | set | messageid: <1598424705.4.0.819395792048.issue41638@roundup.psfhosted.org> |
2020-08-26 06:51:45 | WolfgangFahl | link | issue41638 messages |
2020-08-26 06:51:45 | WolfgangFahl | create | |
|