Skip to content

including the last inserted row id if available - #5

Merged
aosingh merged 2 commits into
aosingh:masterfrom
marekyggdrasil:master
Dec 30, 2020
Merged

including the last inserted row id if available#5
aosingh merged 2 commits into
aosingh:masterfrom
marekyggdrasil:master

Conversation

@marekyggdrasil

Copy link
Copy Markdown
Contributor

I find it very useful to have the id of the last row that has just been inserted.

Before this change, executing insert query would result in something of the form

{'error': None, 'items': [], 'row_count': 1}

after this change we get something like

{'error': None, 'items': [], 'lastrowid': 7, 'row_count': 1}

@aosingh aosingh left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @marekyggdrasil

Thank you for creating a pull request.

We could simplify the code and remove variables lastrowid and ret

As documented here, lastrowid is either set or it is None. So, something like this would be simple.

if self._cursor.lastrowid:
    result['lastrowid'] = self._cursor.lastrowid

@marekyggdrasil

Copy link
Copy Markdown
Contributor Author

Great suggestion @aosingh thanks for reviewing the PR. I just implemented the change you requested. Feel free to let me know if something more is required.

@aosingh
aosingh merged commit 2968a65 into aosingh:master Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants