mrkamel/search_cop

Postgres DatetimeFieldOverflow

harlantwood opened this issue · 5 comments

We have had a few production errors like this one:

The user is searching for 00393488235373. Searchcop searches a number of fields, including some which are date/timestamps, treating this integer as a year. Postgres gets upset because the year is too large for it, and crashes, something like:

PG::DatetimeFieldOverflow: ERROR:  date/time field value out of range: "393488235373-01-01 00:00:00.000000"
LINE 1: ...'%00393488235373%' OR ("accounts"."created_at" >= '393488235...
                                                             ^
: SELECT [...snipped...] WHERE (("accounts"."first_name" ILIKE '%00393488235373%' OR "accounts"."last_name" ILIKE '%00393488235373%' OR "accounts"."email" ILIKE '%00393488235373%' OR "accounts"."phone" ILIKE '%00393488235373%' OR ("accounts"."created_at" >= '393488235373-01-01 00:00:00.000000' AND "accounts"."created_at" <= '393488235373-12-31 23:59:59.999999') OR  [...snipped...] 

Hi, thanks for the report. Should now be fixed in master by limiting the year-recognition to YYYY. However, now we're running into a Y10K bug :-)

Awesome, thanks for the quick fix!

I'll set a calendar reminder for 9999 to file a bug : )

v1.0.6 is out to officially fix this

Great, thanks.