datamapper / do

DataObjects
147 stars 74 forks source link

Return mysql broken zero date as nil #37

Closed natano closed 12 years ago

travisbot commented 12 years ago

This pull request fails (merged da230f34 into f3eec338).

mkristian commented 12 years ago

a little spec would be great so we can keep that can ensure that behaviour for both MRI and JRuby

dbussink commented 12 years ago

Is there a way to spec this behavior? Also, shouldn't we check whether all fields are 0 separately? Isn't there a better way to verify whether this is NULL? Maybe through a mysql specific function?

dbussink commented 12 years ago

What if we want to store the date -0002 - 01 - 01 (so 2 years BC). I know this is somewhat far fetched and MySQL doesn't support dates like that. Postgres for example does and this parser is a generic parser that needs to handle any valid date for different databases.

It's therefore necessary to check each component for 0 and not just add them all and check that.

mkristian commented 12 years ago

taking your words then for postgres the date 0000-00-00 is also a valid date ?! but maybe we can live with one exceptional case.

dbussink commented 12 years ago

No, 0000-00-00 isn't valid on Postgres. But dates before BC are valid in Postgres. -0002-01-01 there would be valid, so with the old fix that case would break.