Skip to content

Commit

Permalink
sqlite: use lastrowid instead of RETURNING id
Browse files Browse the repository at this point in the history
RETURNING was introduced quite recently and is not available in all sqlite
versions.
  • Loading branch information
efiop committed Jan 31, 2023
1 parent b5997ed commit f22402d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, windows-latest, macos-latest]
os: [ubuntu-20.04, windows-latest, macos-latest]
pyv: ['3.8', '3.9', '3.10', '3.11']

steps:
Expand Down
6 changes: 3 additions & 3 deletions src/sqltrie/sqlite/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ def _create_node(self, key):
node_key = longest_prefix
for name in key[len(longest_prefix) :]:
node_key = (*node_key, name)
row = self._conn.execute(
cur = self._conn.execute(
"""
INSERT OR IGNORE
INTO nodes (pid, name)
VALUES (?, ?)
RETURNING id
""",
(pid, name),
).fetchone()
nid = row["id"]
)
nid = cur.lastrowid
self._ids[node_key] = nid
pid = nid

Expand Down

0 comments on commit f22402d

Please sign in to comment.