Talk:Incidents/2018-02-26 WikibaseQualityConstraints
Valid SQL
The
WikiPageEntityMetaDataLookuphad a special safeguard (added in 294340) for this case to avoid costly queries, adding a condition"0". However,Database::selectSQLTextactually turns this condition into a query with noSELECT[sic] clause (instead of something likeWHERE FALSE, whichWikiPageEntityMetaDataLookupprobably intended).
I note that "WHERE 0" is not valid SQL in the first place. MySQL and SQLite accept it, but none of the other databases MediaWiki claims to support do. "WHERE FALSE" works on MySQL and PostgreSQL, but none of the others accept it. Valid SQL might be something like "WHERE 1=0".
"0" turns out to be a particularly unfortunate choice there since PHP considers that string as being empty (in the sense of empty()), so the check in MediaWiki for whether an empty $conds (e.g. empty string, empty array, false, null) was passed to actually mean no WHERE is wanted caught it. Anomie (talk) 15:52, 27 February 2018 (UTC)