jnunemaker/mongomapper — Issue #397: Unique => true errors on Date data type
Author: jafoca
Created: 2012-03-09 16:37:33+00:00
State: open

In a simple Padrino app we were trying to set up a unique requirement on a Date attribute being stored by MongoMapper.

key :date, Date, :unique => true

When trying to save the model we see error:
>BSON::InvalidDocument at /admin/daily_schedules/update/4f5935fb36f50b39eb000050
>Date is not currently supported; use a UTC Time instance instead.

Without the :unique => true requirement the system works.

Suspect that the issue arises from the validator not using the to_mongo / from_mongo converters when checking for uniqueness.