I'm getting this error: Failed to register
- User
I'm getting this error: Failed to register user: ERROR: column "level" is of type membership_level but expression is of type text (SQLSTATE 42804)
here is my query: INSERT INTO user_app_memberships ( user_id, level, expires_at ) VALUES ( 2, 'basic'), $3 ) RETURNING *;
Assistant
I see the issue. You're encountering a type mismatch in your PostgreSQL query. The column "level" is defined as a custom enum type called
membership_level, but you're trying to insert a text value into it.Try this fix:
INSERT INTO user_app_memberships ( user_id, level, expires_at ) VALUES ( $1, COALESCE($2, 'basic'::membership_level), $3 ) RETURNING *;Would you like me to explain how this solution works?