Trying to create medium blob field for MySQL results in a database error. Current case an examples are from running the code during update function call. Though it will most probably produce the same results when defining schema.
Changing size to values of big or normal seemed to be working just fine.
Code producing an error:
$data_spec = [
'description' => 'Serialized data',
'type' => 'blob',
'serialize' => TRUE,
'not null' => FALSE,
'size' => 'medium',
];
$schema = \Drupal::service('database')->schema();
$schema->addField('some_table', 'data', $data_spec);
The error produced is:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL DEFAULT NULL COMMENT 'Serialized data'' at line 1: ALTER TABLE {some_table} ADD `data` NULL DEFAULT NULL COMMENT 'Serialized data';
It does seem that required data type is not detected correctly in in case size is set to medium.
Running similar code with MySQL specific hint works as expected:
$data_spec = [
'description' => 'Serialized data',
'type' => 'blob',
'mysql_type' => 'blob',
'serialize' => TRUE,
'not null' => FALSE,
'size' => 'medium',
];
$schema = \Drupal::service('database')->schema();
$schema->addField('some_table', 'data', $data_spec);
| Comment | File | Size | Author |
|---|
Issue fork drupal-3118014
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pjotr.savitski commentedComment #3
xjmComment #4
sanjayk commented@pjotr.savitski
I have check the same issue and made a patch please apply this patch. If you still any issue please let me know.
Comment #5
sanjayk commentedComment #6
daffie commentedOn MySQL there is no such thing as a medium blob field. MySQL has a "blob" field and a "longblob" field. In Drupal they have respectively the sizes are named "normal" and "big". The "mysql_type" is the direct name MySQL field name, which is here "blob" and that is why it works. Adding the size type "medium" is to me not something that makes the MySQL database driver better. Therefor, for me it is a "won't fix".
Comment #7
gappleMySQL has Blob sizes corresponding to the available Text field sizes: TINYBLOB (255 bytes), BLOB (65KiB), MEDIUMBLOB (16MiB), and LONGBLOB (4 GiB)
https://dev.mysql.com/doc/refman/5.7/en/blob.html
https://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html#data-t...
The additional field type mappings would also have be applied to the pgsql and sqlite drivers (though both only use a single blob type regardless of size).
Comment #8
gappleComment #10
sanjayk commentedJust run test cases for 9.2
Comment #15
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #17
amateescu commentedI just closed 2 issues in the IP address fields module which show that this is a real problem that needs to be fixed in core:
- #3467884: Unable to execute related tests via sqlite successfully
- #3268730: Error when the project is over postresql
Comment #19
gappleMade a MR with changes from patch file.
Comment #20
smustgrave commentedAppears to have pipeline issues.
Comment #21
gappleQuick fix to add new words to cspell dictionary
Comment #22
arunsahijpal commentedThe pipeline is all green now and the MR seems to be working fine
Hence moving it to RTBC.
Comment #23
heddn+1 on RTBC. I don't think additional test coverage is needed. LGTM.
Comment #24
smustgrave commentedPostponed #3030154: layout_builder__layout_section column hitting database limit on this one.
Comment #25
daffie commentedI think we should add testing for this change. Lets add testing for:
- as a field of a new table
- add a field to an existing table
- change an existing field to use the new field type
For each way to create a field add a check that the field is of the correct type and do that for each new blob type.
Please add a change record
Changed the issue to a feature request.