Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294253

Postgres entity queries doesn't treat multiple IN conditions correctly

$
0
0

A recent Search API commit (#2574611-36: Unify our two task systems) broke the tests (and module) on Postgres. After a bit of investigating I found the culprit to be an apparent Core bug regarding entity queries.

This method, as you can see, takes potentially multiple conditions and integrates them into an entity query. The 'IN' operator and an array type cast is used to uniformly treat single-valued and multi-valued conditions.

However, while it worked fine for MySQL and SQLite, the Postgres driver couldn't work with this correctly, but produced a query like the following:

SELECT 1 AS expression
FROM 
{search_api_task} base_table
INNER JOIN {search_api_task} search_api_task ON search_api_task.id = base_table.id
WHERE  (LOWER(search_api_task.type) IN (LOWER(:value1))) AND (LOWER(search_api_task.index_id) IN (LOWER(:value1)))

Note that both placeholders are called :value1, although they are different values. This, of course, leads to false matches.

I tried to create a test case to showcase this bug more clearly, or reproduce it with Core entity types, but I unfortunately didn't succeed. I don't really know what circumstances have to be present for this bug to occur. The entity type in question doesn't have a data table, though, and just uses a single table to store all fields. Maybe it only works with base fields? (Tried with nodes'nid and type fields, though, and also failed.)

Anyways, I know that the problem only exists with IN conditions since we managed to find a workaround by just using = instead where possible (see #2574611-49: Unify our two task systems).


Viewing all articles
Browse latest Browse all 294253

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>