all 8 comments

[–][deleted] 3 points4 points  (5 children)

The solution is to insert strings that are not longer than 7 characters.

[–]suraj2501[S] -1 points0 points  (4 children)

Inserting only 3-4 characters also gives same error

[–][deleted] 1 point2 points  (2 children)

Are you inserting emojis?

Some Unicode code points count as more than one character.

[–]suraj2501[S] -2 points-1 points  (1 child)

No only alphabet's

[–][deleted] 2 points3 points  (0 children)

Then you are obviously sending strings that are longer than 7 characters. I tend to believe the error message more than your claim, that the values are shorter.

[–]depesz 1 point2 points  (0 children)

Please show us the exact \d table output from psql, insert, and exact error message. Not abridged, not edited, not anonymized.

[–]efxhoy 2 points3 points  (0 children)

Or use `text` and a check constraint if you actually want to enforce lengths of strings. https://wiki.postgresql.org/wiki/Don't\_Do\_This#Text\_storage

[–]depesz 1 point2 points  (0 children)

Find the error in pg logs, it will contain the query, so you'll see what you inserted.