Operator error when comparing bigint and character varying values: (Postgrex.Error) ERROR 42883 (undefined_function) operator does not exist: bigint = character varying

Is this correct? It’s not supposed to be the same value as users.id? Can you describe what this column represents?

If so, then you need an additional column that is a foreign key to your users table. I would recommend that the foreign key column be named user_id and you find a more explicit name for your current user_id column.

1 Like

TBH I have no idea - even if those hex digits are decoded to an integer, that value is waaaaaaaaay too big (like 50000x too big, just shy of 80 bits long) to fit in a bigint column; whatever it is doesn’t seem to refer to the user.id column.

How is that value supposed to be used to find the corresponding record in user for a given user_session row?

Is it supposed to be a foreign key? You’ve posted two migrations trying to set it up as one; one that wasn’t being run and the other that failed because of a type mismatch.

The code being tested doesn’t fit together properly, so the test code never has a chance to work right.

Going all the way back to the error message at the beginning of this post: that many_to_many relationship assumes that there is a column on the join table (user_session.user_id) that can be joined to user.id. If that assumption is not satisfied by the tables created by the migration, the association will not work.

1 Like