Steps to reproduce:
Add a Boolean field to a content type. In the 'Options' text area enter two values, e.g.,
Options:
True
False
Create Content > You Content Type
Select one of the options. Submit.
Observe:
* PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'False' for column 'field_torf_value' at row 1: INSERT INTO {field_data_field_torf} (etid, entity_id, revision_id, bundle, delta, language, field_torf_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] => 1 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => custom [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => zxx [:db_insert_placeholder_6] => False ) in field_sql_storage_field_storage_write() (line 421 of /var/www/vc/drupal-head/drupal/modules/field/modules/field_sql_storage/field_sql_storage.module).
The website encountered an unexpected error. Please try again later.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | field_list_tests_quickfix.patch | 2.91 KB | yched |
| #19 | field_list_ui-606934.with-tests.03.patch | 5.69 KB | matt2000 |
| #17 | field_list_ui-606934.with-tests.02.patch | 5.67 KB | matt2000 |
| #15 | field_list_ui-606934.with-tests.01.patch | 5.86 KB | matt2000 |
| #11 | field_list_ui-606934.with-tests.patch | 3.99 KB | matt2000 |
Comments
Comment #1
johanneshahn commentedat the field description where you define the key|value pairs
i notice following text:
"The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and must be a numeric value. The label is optional, and the key will be used as the label if no label is specified."
think the best way is to check the correct formatting of user input
before saving the field.
Comment #2
johanneshahn commentedtry this path
Comment #3
johanneshahn commentedtry again
Comment #5
matt2000 commentedthis needs to be revisited before release...
Comment #6
yched commentedThat one should apply. Additionally, checks that we have no more or no less than 2 values.
Comment #9
matt2000 commentedThis looks good, and solves the bug from a technical standpoint.
The form description text could probably also use some love to prevent this error from appearing in the first place, but that's a separate issue.
Comment #10
webchickLet's get tests for this, please.
Comment #11
matt2000 commentedMy first time writing tests. How's this?
Comment #12
yched commentedYay, thanks for stepping in Matt !
The test should go in field/modules/list/list.test rather than in field_ui/field_ui.test.
This will probably warrant a separate testcase class, with its own setUp() inspired from the one in field_ui.test
Formatting + misses trailing point.
+ ideally, we would also test the other failures for other 'list' types ;-)
This review is powered by Dreditor.
Comment #13
matt2000 commentedI wondered about which module to place these test with, but they only apply to the form that's generated by field_ui; i.e., if field UI module is not being used, there is no reason to run these test, I think?
Which brings up the idea... do we need some kind of error handling or unit tests for the API functions to make sure API users don't make the same mistake?
Comment #14
yched commentedNot exactly. The code is in a hook that is called by field_ui and won't be executed if field_ui isn't enabled, but this doesn't change the fact that it's code from list.module that is being tested.
Exact same reason why other list tests, text tests, options tests, etc. are in the field type modules, and not in field API.
You mean field_create_field() should throw an exception if the list of values is not valid ? Well, theoretically yes. Er, I'm not sure we'll be there in D7, though.
Comment #15
matt2000 commentedOK, how about this?
Comment #16
yched commentedGreat ! Minor remarks:
group should be 'Field Types'
Nitpick: "Number" field type is something else.
I'd suggest "Test 'List (number)' field type.
Same remark applies to "Test Text type below".
As a side note: those 3 different 'list' types are on their way out: #622614-3: Consider reducing the number of field types
That check is overkill. Plz just remove it.
Really nitpick: please put the tests in the following order:
- List
- List (number)
- List (text)
- Boolean
Once those are fixed, this is RTBC.
This review is powered by Dreditor.
Comment #17
matt2000 commentedAs requested...
Comment #18
yched commentedOops, 2 last really minor details.
Don't capitalize the F(ield), to be consistent with the existing 'List field tests'
The other comments don't have the word 'field'
This review is powered by Dreditor.
Comment #19
matt2000 commented(2) I noticed that when I looked at my last attachment after posting, but hoped it would sneak by.... ;-)
Comment #20
yched commented:-p
Thanks matt !
Comment #21
dries commentedLooks great. Great tests too, matt. Committed to CVS HEAD.
Comment #22
yched commentedQuickfix: test category should be 'Field Types', not 'Field types'. Now we have both on admin/config/development/testing (and it causes the JS expand/collapse to act strangely BTW).
+ trailing whitespace fixes.
hint to @matt2000 for later patches: would be great if you configured your IDE to remove them automatically on file save ;-)
Comment #23
matt2000 commentedDone. Thanks for the tip.
Also, the quickfix patch looks good, so RTBC++.
Comment #24
webchickWell, actually, core's capitalization standard is "Sentence case", so we should fix the one that are "Field Types" to "Field types" so they're all consistent.
Comment #25
yched commentedre @webchick #24: OK - #658358: inconsistencies in field type tests 'Group'.
Setting this one back to 'fixed'.