Hi sickill,

> As I remember there was a talk about date/time properties and their
> precisions some time ago (could be a year ago).
> I remember that someone had following argument against more precision:
> if you set updated_at to 2009/06/26 12:25:00.123456 and DB will store
> milliseconds as .1234 (because that's its precision) this would mean
> that we have different data in DB and in model. Probably this could
> make tracking dirty attributes more tricky.

Ahh, yeah, I remember this now, and I think it was about a year ago.

The problem was that people were writing specs that persisted a
resource, then they fetched it back, but it wouldn't match the
original because of differences in time precision.  Time#== and
Time#eql? will only return true if every part of the Time objects are
equal, even milliseconds, which is totally what you'd expect.

I don't remember if this prompted any changes on our part in DM or DO,
or if it was the reason for selecting DateTime instead of Time in dm-
timestamps though.

> But I think we can come up with some solution to this, ie cast time to the
> precision which DB uses upon attribute assignment. What do you think?

Truncating the time upon attribute assignment should be possible,
although I don't know if it's a good idea yet.  It seems a big too
magical to me, but I'd like to hear other people's opinion on this.

Even if we did decide to do it, I'd wait until the
DataMapper::Property class is refactored (it's going to be split up
into a single base class, and the logic for each primitive separated
into subclasses).  Once this is done it will be much simpler to add
Time specific casting logic to DateTime::Property::Time for example.

> Does property have access to such information like underlying
> datetime/timestamp/whatever column's precision?

Currently there is nowhere to get this information from, although it
wouldn't be too difficult to add.

Dan
(dkubb)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to