Problem description:
Decimal field (field_decimal- machine name) attached to some content type.
Field settigs:
Precision - 10
Scale - 5
Screenshot of settings:
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
I get this error:
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.
Comment | File | Size | Author |
---|---|---|---|
#16 | After_patch.png | 48.69 KB | vikashsoni |
#16 | Before_patch.png | 79.28 KB | vikashsoni |
#12 | value_out_of_range-2461439-12.patch | 738 bytes | 3ssom |
#4 | field-number_decimal-2461439-9769575-D7.patch | 1.43 KB | bigferumdron |
field_data.png | 1023 bytes | bigferumdron |
Comments
Comment #1
bigferumdron CreditAttribution: bigferumdron commentedComment #2
bigferumdron CreditAttribution: bigferumdron commentedComment #4
bigferumdron CreditAttribution: bigferumdron commentedComment #5
bigferumdron CreditAttribution: bigferumdron commentedComment #6
damien_dd CreditAttribution: damien_dd commentedHi,
I still got this error with Drupal 7.41 .
Is that bug confirm?
Damien.
Comment #7
yuraosn CreditAttribution: yuraosn as a volunteer and commentedHi.
on Drupal 7.42 on the same error
Comment #8
BR0kENWe need an additional patch, which will handle the input based on the database column specification.
Comment #9
3ssom CreditAttribution: 3ssom at Ministry Of Housing for Ministry Of Housing commentedHello,
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
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!
Comment #10
3ssom CreditAttribution: 3ssom at Ministry Of Housing for Ministry Of Housing commentedPatch attached!
Comment #12
3ssom CreditAttribution: 3ssom at Ministry Of Housing for Ministry Of Housing commentedDiscard my last patch ,, I diffed the whole thing out my project sorry!
hope this one is ready!
Comment #13
3ssom CreditAttribution: 3ssom at Ministry Of Housing for Ministry Of Housing commentedComment #14
apadernoComment #15
BR0kENComment #16
vikashsoni CreditAttribution: vikashsoni as a volunteer and at Zyxware Technologies commented@bigferumdron thanks for the patch
patch is working fine for me for reference sharing screenshot