Search code examples
ruby-on-railspostgresqlpgactive-relation

Postgres adapter appears to return nil dates for columns that actually have non-NULL values


Postgres 9.0.4
Rails 3.0.7
AR 3.0.7
pg 0.12.2

I have a table with 3 records in it with DATE column values of '0001-01-01 BC' (not sure how they got in there in the first place, there is no default value set on the column).

When I request these records and then query for this date column value through ActiveRelation, they return nil, but they are actually NOT NULL in the database.

See:

[3] pry(main)> User.where(birthday: '0001-01-01 BC').map {|u| u.birthday}
=> [nil, nil, nil]

Anyone seen anything like this or have any idea what's going on here?

Thanks, Wes


Solution

  • This looks like an issue that was fixed with this pull request. Updating rails should solve your problem.