Open fy0 opened 4 years ago
Did you try pure asyncpg? Because tortoise use it in deep.
@fy0 I can't reproduce this bug with your example:
Output:
(0, [])
(1, [<Record id=10 name='2'>])
@fy0
Actually, I think I've got what do you mean. With AsyncpgClient
we return the length of the rows, which returned from the query, and asyncpg didn't return anything in the response on INSERT operation. On the other hand, SqliteClient returns (connection.total_changes - start) or len(rows)
so or count of changes, or length of rows in a query. I believe with asyncpg we don't have such information like total changes. So, it's not really a lastrowid
returned.
Maybe could be better to have similar signatures for results in all clients? What do you think @long2ice ?
@fy0 Actually, I think I've got what do you mean. With
AsyncpgClient
we return the length of the rows, which returned from the query, and asyncpg didn't return anything in the response on INSERT operation. On the other hand, SqliteClient returns(connection.total_changes - start) or len(rows)
so or count of changes, or length of rows in a query. I believe with asyncpg we don't have such information like total changes. So, it's not really alastrowid
returned.
Right, sqlite have a lastrowid api, It is said that MySQL have a similar one.
To postgres, you can append 'returning {primary_key}'
after insert statement.
Describe the bug Execute raw sql insert, result is incorrect.
To Reproduce
Expected behavior (1, [])
Additional context It would be better to return lastrowid