I am working on building a query for nodes that have a few custom fields (field types). The fields are custom build in a custom module with a custom schema. When I execute the query:

 $query = \Drupal::entityQuery('node')
    ->condition('type', 'place');
 $query->condition('my_custom_field', '', '<>');

It fails with a message indicating that: node__my_custom_field.my_custom_field_value does not exist (NOT found). This is correct the table has a custom schema for this field _value does not exist:

 drush sqlq "describe node__my_custom_field"

bundle  varchar(128)    NO  MUL     
deleted tinyint(4)  NO  PRI 0   
entity_id   int(10) unsigned    NO  PRI NULL    
revision_id int(10) unsigned    NO  MUL NULL    
langcode    varchar(32) NO  PRI     
delta   int(10) unsigned    NO  PRI NULL    
my_custom_field_title   text    YES     NULL    
my_custom_field_description text    YES     NULL

How do I make my entity field query work with this field custom schema?

1 Answer 1


It looks like your custom field type has title and description columns rather than value (the default Drupal assumes if you don't tell it otherwise).

You can specify the field column to use with . notation like this:

$query->condition('my_custom_field.title', '', '<>');
$query->condition('my_custom_field.description', '', '<>');

If you want the system to consider, for example, the title property as the default instead of value, you can implement FieldItemBase::mainPropertyName() in your field class:

public static function mainPropertyName() {
  return 'title';

That would make your original line work for the title column:

$query->condition('my_custom_field', '', '<>');
  • Thanks .. I should have figured this one ..
    – awm
    Commented Oct 29, 2021 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.