tomyeh / postgresql

Dart Postgresql database library.
https://quire.io
BSD 2-Clause "Simplified" License
15 stars 7 forks source link

<Summarize your issues here>Problem Inserting Data in a Table with Autoincrement id -postgresql2 0.5.1. #3

Closed sortie closed 6 years ago

sortie commented 6 years ago

From @finsignaresv on August 15, 2018 18:18

URL: https://pub.dartlang.org/packages/postgresql2#-installing-tab-

There is an error when somebody try to insert data in a table that has an autoincrement id:

I/flutter ( 1922): Query error: pgpool9:30264:9 ERROR 23505 duplicate key value violates unique constraint "table_pkey".

Is possible to insert the first row in the table, but if you try to upload a second one you will have this error, because the id do not increase automatically.

I hope you can fix this error soon.

Best regards,

Francisco.

Copied from original issue: dart-lang/pub-dartlang-dart#1531

tomyeh commented 6 years ago

It is application's job, not driver's. Basically, you can use upsert or update-then-insert-with-query to avoid it.