tortoise / tortoise/tortoise-orm

Last inserted row method

Open
#380 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
5.6k
Forks
516
Avg merge
2d 21h
Merged PRs (30d)
9

Description

Describe the solution you'd like
Having a clear method to get the last inserted row, useful when you want to use last inserted row at a place where you don't have access to the insertion return

Describe alternatives you've considered
The only alternatives right now are :
Table.all().order_by("-id").first() -> QuerySetSingle
Table.all().order_by("-id").limit(1) -> QuerySet

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing Table.all().order_by("-id").first() and limit(1) alternatives to understand the ORM entry points involved. Define the expected last-inserted-row behavior across the supported database backends, then verify that the new method returns the inserted row when the insertion result is not available.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.