Problem/Motivation

When I updated Feeds on one of my sites, I got this error when I tried to update the database:

drush updb
 -------- ----------- --------------- ----------------------------------------- 
  Module   Update ID   Type            Description                              
 -------- ----------- --------------- ----------------------------------------- 
  feeds    8009        hook_update_n   8009 - Adds the 'periodic_import' field  
                                       to feeds_feed entities.                  
 -------- ----------- --------------- ----------------------------------------- 


 Do you wish to run the specified pending updates? (yes/no) [yes]:
 > 

>  [notice] Update started: feeds_update_8009
>  [error]  Unable to parse the column type TINYINT 
>  [error]  Update failed: feeds_update_8009 
 [error]  Update aborted by: feeds_update_8009 
 [error]  Finished performing updates. 

My first guess is that this is caused by using SQLite which doesn't have a TINYINT data type. I've run into this a bit before in the past.

If anyone wants me to test any potential fixes, let me know.

TIA.

Comments

bogdog400 created an issue. See original summary.

megachriz’s picture

As far as I can see, Feeds doesn't explicitly set a field as TINYINT. Even the new installed field "periodic_import" is not TINYINT. The field that does result into a tinyint on MySQL is the field "status". This is defined as 'boolean' in Feed.php:

$fields['status'] = BaseFieldDefinition::create('boolean')
  ->setLabel(t('Importing status'))
  ->setDescription(t('A boolean indicating whether the feed is active.'))
  ->setDefaultValue(TRUE);

So to me this looks like to be an issue in Drupal Core, not in Feeds.

#3410600: TINYINT clogs updb for path_alias looks like to be related. I see you that you opened that issue.

bogdog400’s picture

Yes. It seems like I've been having these issues since I've been using SQLite pretty extensively lately.

But if you think it's CORE, why did it appear when trying to run an update for Feeds?

megachriz’s picture

@bogdog400
Feeds doesn't set any column to TINYINT explicitly. It uses API's in Drupal Core to define fields for the feeds_feed entity type. Drupal Core then creates the SQL tables and fields. It looks like a field of type 'boolean' results into a database column becoming a TINYINT. The code that specifically does that is defined in Drupal Core.

bogdog400’s picture

Okay. The problem lies with CORE, but this update with Feeds exposes it. So can Feeds check what CORE has done before running the update?

joelpittet’s picture

Status: Active » Closed (works as designed)

@bogdog400 you will need to file or find an issue in core to address your problem your experiencing.

We can only address issues we have tests for and I can’t think of reasonable test for this. Feel free to write one if you have an idea that relates in scope to feeds. Though I implore you to contribute to fixing the problem at the source. Feel free to relate the core issue to this for context.

It seems you agree the problem is not here so I will close this as works as designed.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

bogdog400’s picture

For any readers looking for a solution, I wanted to summarize what I ended up doing. After discussing this with an AI, the AI suggested that I could just temporarily edit the core code and insert the right value of TINYINT. So I did that and the update went through without a hassle.

Here's the code I added to web/core/modules/sqlite/src/Driver/Database/sqlite/Schema.php:

protected function introspectSchema($table) {
    $mapped_fields = array_flip($this->getFieldTypeMap());
    $mapped_fields['TINYINT'] = 'int:tiny';  // <--- ADD THIS LINE HERE
    $schema = [
      'fields' => [],
// ...