-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LastInsertId method returns 0? #13
Comments
This indeed isn't supported. The main obstacle is to get at the name of the primary key sequence. |
Subscribing, very useful |
If you use not ancient PostgreSQL, you can do |
Yes, returning is nice, but to implement LastInsertId, how would we know the exact name of the id column without guessing? |
I guess there is no way without fetching table structure. And even then you can't do anything for table like Basically, |
I'm using "SELECT LASTVAL()" which appears to work OK, and alternatively a query using eg. " RETURNING iKey" appears to work OK. |
I don't know if this driver implements the LastInsertId method of the Result type of the database/sql package or not but when I tried to use it I got back a 0 but in Postgres I could see the last ID was 98.
The way that I tried it out is as follows:
The text was updated successfully, but these errors were encountered: