Skip to content
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

Feature request: helpful error message on importing records with mix of null and non-null ids #702

Open
bblack opened this issue Aug 21, 2020 · 1 comment

Comments

@bblack
Copy link

bblack commented Aug 21, 2020

I've just spent a fair amount of time tracking down an issue that manifested in our app as

PG::NotNullViolation: ERROR:  null value in column "id" violates not-null constraint

This was surprising, as I expect this gem to either

  • not specify an id in the query, allowing postgres (in our case) to use the default column value (which is given by a seq), or
  • specify an id with an expression referring to that sequence, as it usually does

@jkowens notes in another issue that

you cannot mix records that do not have an id set with those that do because the resulting sql statement will be invalid

This seems like an easy condition to detect, and possible actions include

  • fill in unspecified id values with the "next sequence value" expression
  • raise an error with a more helpful message
@doutatsu
Copy link

doutatsu commented Apr 6, 2021

I've just experienced this issue and took me quite a bit of time to realise what was going on. So 👍🏻 from me as well, there should be a nicer error message to help with debugging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants