This commit is contained in:
retoor 2025-07-04 20:07:14 +02:00
parent 695efe6d2f
commit 1a7cc682f6

13
ads.py
View File

@ -143,7 +143,7 @@ class AsyncDataSetConnector:
"deleted_at": None, "deleted_at": None,
**args, **args,
} }
cols = "`" + "`, `".join(record) + "`" cols = "`" + "`, `".join(record) + "`"
qs = ", ".join(["?"] * len(record)) qs = ", ".join(["?"] * len(record))
sql = f"INSERT INTO {table} ({cols}) VALUES ({qs})" sql = f"INSERT INTO {table} ({cols}) VALUES ({qs})"
await self._safe_execute(table, sql, list(record.values()), record) await self._safe_execute(table, sql, list(record.values()), record)
@ -249,9 +249,6 @@ class AsyncDataSetConnector:
return default return default
class TestAsyncDataSetConnector(unittest.IsolatedAsyncioTestCase): class TestAsyncDataSetConnector(unittest.IsolatedAsyncioTestCase):
async def asyncSetUp(self): async def asyncSetUp(self):
@ -321,15 +318,15 @@ class TestAsyncDataSetConnector(unittest.IsolatedAsyncioTestCase):
async def test_inject(self): async def test_inject(self):
await self.connector.insert("people", {"name": "John Doe", "index": 30}) await self.connector.insert("people", {"name": "John Doe", "index": 30})
await self.connector.insert("people", {"name": "Alice", "index": 23}) await self.connector.insert("people", {"name": "Alice", "index": 23})
await self.connector.delete("people", {"name": "John Doe","index": 30}) await self.connector.delete("people", {"name": "John Doe", "index": 30})
self.assertIsNone(await self.connector.get("people", {"name": "John Doe"})) self.assertIsNone(await self.connector.get("people", {"name": "John Doe"}))
count = await self.connector.count("people") count = await self.connector.count("people")
self.assertEqual(count, 1) self.assertEqual(count, 1)
async def test_insert_binary(self): async def test_insert_binary(self):
await self.connector.insert("binaries",{"data":b"1234"}) await self.connector.insert("binaries", {"data": b"1234"})
print(await self.connector.get("binaries",{"data":b"1234"})) print(await self.connector.get("binaries", {"data": b"1234"}))
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()