mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-05-05 06:30:07 +08:00
fix: orm bugs.
This commit is contained in:
@@ -5,15 +5,17 @@ class Insert:
|
||||
self._columns = data.items()
|
||||
|
||||
def __gen_id(self) -> int:
|
||||
self._connector.execute(f"SELECT MAX(id) FROM {self._table_name}")
|
||||
max_id = self._connector.fetchone()[0]
|
||||
self._connector.execute(
|
||||
f"""
|
||||
SELECT MAX(id) FROM {self._table_name}
|
||||
""",
|
||||
)
|
||||
max_id = self._connector.fetchone(keys=["id"]).get("id")
|
||||
if max_id is None:
|
||||
return 1
|
||||
return max_id + 1
|
||||
|
||||
def one(self, data: dict):
|
||||
if data["id"] is not None:
|
||||
raise ValueError("id must be None")
|
||||
_id = self.__gen_id()
|
||||
data["id"] = _id
|
||||
columns = ", ".join(data.keys())
|
||||
|
||||
Reference in New Issue
Block a user