Steps to repeat:
1. Enable Number module.
2. Create a new content type with a Float field type.
3. Create a new node using a value like '123.' or '9.' (w/o quotes) for the Float field type.

Expected Results:
Print an error message for invalid value. An alternative would be remove the decimal point (save '123' or '9' in the given examples).

Actual Results:
PDOException: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'field_number_value' at row 1: INSERT INTO {field_data_field_number} (entity_type, entity_id, revision_id, bundle, delta, language, field_number_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] => 199 [:db_insert_placeholder_2] => 199 [:db_insert_placeholder_3] => teste [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 1. ) in field_sql_storage_field_storage_write() (line 451 of /path/to/drupal/modules/field/modules/field_sql_storage/field_sql_storage.module).

#1 fix_float_formatting_for_decimal_and_no_following_numbers-2042411-1.patch683 bytesgeneralredneck
PASSED: [[SimpleTest]]: [MySQL] 40,348 pass(es). View


generalredneck’s picture

Status:Active» Needs review
new683 bytes
PASSED: [[SimpleTest]]: [MySQL] 40,348 pass(es). View

I got this one...

Turns out that if we were using Decimal fields... this would work... however floats are a special case since we can't "round" them. What I ended up doing was converting the variable to a floatval. This should take care of all cases with no side-effects AFAIK.