entity_metadata_table_query is like this:

/**
 * Callback for querying entity properties having their values stored in the
 * entities main db table.
 */
function entity_metadata_table_query($entity_type, $property, $value, $limit) {
  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type', $entity_type, '=')
        ->entityCondition($property, $value, '=')
        ->range(0, $limit);
  $result = $query->execute();
  return array_keys($result[$entity_type]);
}

But instead of the entityCondition for the $property I think propertyCondition should be used.
I'm attaching a patch for it.

Comments

pcambra’s picture

StatusFileSize
new769 bytes
fago’s picture

Status: Active » Needs review

Makes sense, let's let the test bot run.

Status: Needs review » Needs work

The last submitted patch, 1041240.patch, failed testing.

pcambra’s picture

Status: Needs work » Needs review
StatusFileSize
new877 bytes

The problem was that an '=' was being forced, I've added a previous check to see if the $value is an array and then use 'IN' instead.
Fix attached.

Status: Needs review » Needs work

The last submitted patch, entity-1041240.patch, failed testing.

pcambra’s picture

StatusFileSize
new878 bytes

Oops, sorry, wrong path

pcambra’s picture

Status: Needs work » Needs review
fago’s picture

Status: Needs review » Needs work

>+ $condition = is_array($value) ? 'IN' : '=';
This is not really the condition, it's the operator.

Anyway, the current behaviour the tests are testing is the default behaviour of the db-tng condition using IN for arrays. However, this does not really work if the property value is itself an array, what might occur. So better let's default to '=' like EFQ, while we could add support for some basic operations too. Maybe, based upon based on the operations efq supports?

For just fixing the actual bug, it would suffice to just go with the default '=' for now + to fix the tests to follow that.

pcambra’s picture

Status: Needs work » Needs review
StatusFileSize
new1.64 KB

Ok, then this one will do it by now.

Status: Needs review » Needs work

The last submitted patch, entity-1041240.patch, failed testing.

fago’s picture

Status: Needs work » Needs review

#9: entity-1041240.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, entity-1041240.patch, failed testing.

pcambra’s picture

Status: Needs work » Needs review
StatusFileSize
new1.63 KB
rszrama’s picture

StatusFileSize
new1.78 KB

I noticed another problem with this function during testing related to #1044308: "Fetch entity by property" has a configuration and evaluation problem. The function entity_metadata_table_query() executes an EntityFieldQuery and returns a value from the array without first checking for results. If no entities with the specified property are found, this results in warnings. Attached patch looks to see if results were returned for the request entity and returns an empty array if not.

rszrama’s picture

Status: Needs review » Reviewed & tested by the community

Do I count as pcambra's community? : D

fago’s picture

Status: Reviewed & tested by the community » Fixed

hm, I'm unsure.. ;)
Anyway, patch looks great! Thanks, committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.