Problem/Motivation

Using Postgresql backend the flag_bookmark view fail to load content because of type mismatching between entity_id and node_id

Exception in Flag Bookmark list[flag_bookmark]: SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: bigint = character varying LINE 6: ...g flagging_node_field_data ON node_field_data.nid = flagging... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {node_field_data} node_field_data INNER JOIN {flagging} flagging_node_field_data ON node_field_data.nid = flagging_node_field_data.entity_id AND (flagging_node_field_data.flag_id = :views_join_condition_0 AND flagging_node_field_data.uid = :views_join_condition_1) INNER JOIN {users_field_data} users_field_data_node_field_data ON node_field_data.uid = users_field_data_node_field_data.uid WHERE node_field_data.status = :db_condition_placeholder_0) subquery; Array ( [:db_condition_placeholder_0] => 1 [:views_join_condition_0] => bookmark [:views_join_condition_1] => 1 )

Proposed resolution

In file flag/src/Entity/Flgging.php change type of $fields['entity_id'] to integer

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);

    // Add descriptions to the fields defined by the parent method.
    $fields['id']->setDescription(t('The flagging ID.'));
    $fields['flag_id']->setDescription(t('The Flag ID.'));

    // This field is on flaggings even though it duplicates the entity type
    // field on the flag so that flagging queries can use it.
    $fields['entity_type'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Entity Type'))
      ->setDescription(t('The Entity Type.'));

    $fields['entity_id'] = BaseFieldDefinition::create('integer')
      ->setLabel(t('Entity ID'))
      ->setRequired(TRUE)
      ->setDescription(t('The Entity ID.'));

Comments

ilpise created an issue. See original summary.

ilpise’s picture