Problem description:

Decimal field (field_decimal- machine name) attached to some content type.

Field settigs:

Precision - 10
Scale - 5

Screenshot of settings:

decimal_config

When I create node and insert to this decimal field value, where count of digits(whithout '-' character) in the integer part of nubmer

more than 5, for exapmle

field_data

I get this error:

error out of range drupal

PDOException: SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'field_decimal_value' at row 1: INSERT INTO

{field_data_field_decimal} (entity_type, entity_id, revision_id, bundle, delta, language, field_decimal_value) VALUES

(:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4,

:db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 211

[:db_insert_placeholder_2] => 212 [:db_insert_placeholder_3] => demo [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und

[:db_insert_placeholder_6] => 11111111 ) in field_sql_storage_field_storage_write() (line 494 of G:\OpenServer\domains\demosite.loc

\modules\field\modules\field_sql_storage\field_sql_storage.module).

More examples of value:

11111 - no error
-11111 -no error

111111 - error
11111111 - error

11111.11111 - no error
-11111.11111 - no error

111111.11111 -error

etc.

In number module of drupal core there are no validation for that case .

I think that in the next version of drupal core, this error must be fixed.

I create patch to fix this problem.
I hope it will help somebody.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bigferumdron’s picture

Issue summary: View changes
bigferumdron’s picture

Status: Needs work » Needs review
FileSize
1.31 KB

Status: Needs review » Needs work

The last submitted patch, 2: field-number_decimal-2461439-9769575-D7.patch, failed testing.

bigferumdron’s picture

bigferumdron’s picture

Status: Needs work » Needs review
damien_dd’s picture

Hi,

I still got this error with Drupal 7.41 .

Is that bug confirm?

Damien.

yuraosn’s picture

Hi.

on Drupal 7.42 on the same error

BR0kEN’s picture

Version: 7.35 » 7.x-dev
Component: field system » number.module
Assigned: Unassigned » BR0kEN
Status: Needs review » Needs work

We need an additional patch, which will handle the input based on the database column specification.

3ssom’s picture

Hello,

I came across this error when I used (integer) with Number field module ,, but after a searched about it .. the error of:

PDOException :SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column

is all about how database information and specification! here you can see and read about this error:
https://dev.mysql.com/doc/refman/5.7/en/numeric-types.html

the bottom line is here:
https://stackoverflow.com/questions/6921613/mysql-int11-number-out-of-range


An int, with MySQL, is stored on 4 bytes, and, as such, can only contain values between -2147483648 and 2147483647.

622108120237 is greater than 2147483647 ; so it doesn't fit into an int -- looks like you are going to have to use a bigint.

See the Datatypes - Numeric types section of
the MySQL manual, about that.

so the error showing is correct but why Drupal isn't setting the error on the form! this shouldn't be like this! to show an Error out of the form seems buggy! at least form_error() will do.

so I made a patch(small & simple) to handle this error in the form depending on the (database needs) when the rang is out of the limit as mentioned above.

Will attach it on the next comment!

3ssom’s picture

Status: Needs work » Needs review
FileSize
293.42 KB

Patch attached!

Status: Needs review » Needs work

The last submitted patch, 10: value_out_of_range-12537186.patch, failed testing. View results

3ssom’s picture

Discard my last patch ,, I diffed the whole thing out my project sorry!

hope this one is ready!

3ssom’s picture

Status: Needs work » Needs review
apaderno’s picture

Issue tags: -decimal number database field +Decimal numbers
BR0kEN’s picture

Assigned: BR0kEN » Unassigned
vikashsoni’s picture

FileSize
79.28 KB
48.69 KB

@bigferumdron thanks for the patch
patch is working fine for me for reference sharing screenshot