When saving an entity containing a date field with a far value (after 2035), an PDOException occurs :
PDOException: SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column ...

It seems the the database column created by adding a date field on an entity is to small (int(11)) to contain the value of far dates.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

heddn’s picture

The largest date that can be stored in a mysql int column is unix timestamp 2147483647 (Tue, 19 Jan 2038 03:14:07 GMT). Probably should catch that at form validation.

r-mo’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
987 bytes

Any reason not to update schema to use big integer?

DamienMcKenna’s picture

Version: 7.x-2.6 » 7.x-2.x-dev
Status: Needs review » Needs work

This is a great improvement, thank you.

One suggestions is that the old field_schema may be cached when the update script runs, therefore it might not get the "size => big" setting. As a result I suggest adding $schema['size'] = 'big'; before the two db_change_field() calls.

r-mo’s picture

Status: Needs work » Needs review
FileSize
987 bytes

I'd thought of that might be needed but tested the update it seemed to pull in the correct schema without any cache clears. No problem to ensure it's set just in case.

r-mo’s picture

joep.hendrix’s picture

joep.hendrix’s picture

Status: Needs review » Reviewed & tested by the community

#5 works as advertised.

Thanks!

DamienMcKenna’s picture

I want to manually test this on a site with lots of data, to make sure it doesn't time out, but otherwise this looks pretty good.

DamienMcKenna’s picture

A quick reroll as update script 7006 was taken by another issue.

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thank you all.

  • DamienMcKenna committed 355551a on 7.x-2.x authored by r-mo
    Issue #2016787 by r-mo, DamienMcKenna, joep.hendrix, heddn, julien_g:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

pio.fernandes’s picture

Hi, this patch works, but not entirely for me: In my case there's a column of type varchar (called timezone) that should no be submitted to the db_change_field()

Adding new patch

pio.fernandes’s picture

pio.fernandes’s picture

Steven Jones’s picture

And this update is very likely to cause issues for people using non standard field storage backends, since those tables that the code is trying to change may simply not exist.

solideogloria’s picture

Please open a new issue referencing this one if you have a problem. This issue is closed and only maintainers can reopen it.