Published on

Picking up Trailing Spaces in a Column in Postgres


Today I was debugging a prod issue where code was not behaving as expected. It turns out it was due to a DB record being compared to user data where we were expecting the two to match but they did not as one of the entries had a trailing space. Looking at the latest user data revealed no issues with trailing spaces. This just left the DB. The question is how do you visually and easily pick up trailing spaces?

Using the Postgres replace function this is actually quite easy:

	replace(  , ' ','@'),
	person p
where like '%1234567';