MCPcopy Create free account
hub / github.com/piccolo-orm/piccolo / _get_inserted_pk

Method _get_inserted_pk

piccolo/engine/sqlite.py:703–714  ·  view source on GitHub ↗

If the `pk` column is a non-integer then `ROWID` and `pk` will return different types. Need to query by `lastrowid` to get `pk`s in SQLite prior to 3.35.0.

(self, cursor, table: type[Table])

Source from the content-addressed store, hash-verified

701 ###########################################################################
702
703 async def _get_inserted_pk(self, cursor, table: type[Table]) -> Any:
704 """
705 If the `pk` column is a non-integer then `ROWID` and `pk` will return
706 different types. Need to query by `lastrowid` to get `pk`s in SQLite
707 prior to 3.35.0.
708 """
709 await cursor.execute(
710 f"SELECT {table._meta.primary_key._meta.db_column_name} FROM "
711 f"{table._meta.tablename} WHERE ROWID = {cursor.lastrowid}"
712 )
713 response = await cursor.fetchone()
714 return response[table._meta.primary_key._meta.db_column_name]
715
716 async def _run_in_new_connection(
717 self,

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected