Now T210206: Deprecate raw SQL conditions for IDatabase methods (select, insert, etc.) is mostly done, devs should start migrating their codebases away from building raw SQL.
See below as examples of adoption:
- https://gerrit.wikimedia.org/r/c/mediawiki/core/+/970792/
- https://gerrit.wikimedia.org/r/c/mediawiki/core/+/967554/
- https://gerrit.wikimedia.org/r/c/mediawiki/core/+/972431/
Also these regexes can migrate simple cases:
'([A-Za-z_\.]+) ?(=|!=|<|<=|>|>=) ?' . (\$db(?:r|w|))->addQuotes\( (.+?) \) to: $3->expr\( '$1', '$2', $4 \)
and
'([A-Za-z_\.]+) IS NULL OR ([A-Za-z_\.]+) ?(=|!=|<|<=|>|>=) ?' . (\$db(?:r|w|))->addQuotes\( (.+?) \) to: $4->expr( '$1', '=', null )->or\( '$2', '$3', $5 \)
and
'([A-Za-z_\.]+) IS NOT NULL OR ([A-Za-z_\.]+) ?(=|!=|<|<=|>|>=) ?' . (\$db(?:r|w|))->addQuotes\( (.+?) \) to: $4->expr( '$1', '!=', null )->or\( '$2', '$3', $5 \)
Replacements for functions:
- ISQLPlatform::unionQueries => UnionQueryBuilder::execute
- ISQLPlatform::selectSQLText => SelectQueryBuilder::getSQL
- ISQLPlatform::buildSelectSubquery => SelectQueryBuilder::getSQL + new Subquery
- ISQLPlatform::buildGroupConcatField => SelectQueryBuilder::buildGroupConcatField
- ISQLPlatform::makeList => Expression::or / Expression::and / IReadableDatabase::orExpr / IReadableDatabase::andExpr
- ISQLPlatform::buildLike => IReadableDatabase::expr + IExpression::LIKE/IExpression::NOT_LIKE + new LikeValue
- DbQuoter::addQuotes => IReadableDatabase::expr (not all can be replaced, for example when used with other ISQLPlatform::build* functions)