Repository navigation
v1.1.0
Solo Repository 1.1 makes LIKE patterns escape the same way on every supported database and adds Like, which builds such patterns from plain text.
Fixes
LIKEandNOT LIKEescape with\on SQLite, MySQL, MariaDB and PostgreSQL, so\%,\_and\\match%,_and\themselves. SQLite has no default escape character, and underNO_BACKSLASH_ESCAPESneither has MySQL, nor MariaDB for single-byte character sets; there50\%matched50\followed by anything. A LIKE now ends inESCAPE '\'on SQLite andESCAPE X'5C'on MySQL and MariaDB. Both are literals, so patterns with a fixed prefix keep their index ranges. PostgreSQL, which always escapes with\, gets no clause, and LIKE onbyteafields keeps working.
Features
-
Like::escape(),contains(),startsWith()andendsWith()turn plain text, such as a search term, into a pattern that matches it literally:use Solo\Repository\Like; $products->read()->findBy(['name LIKE' => Like::contains($search)]);
Behavior changes
- On SQLite, and on MySQL and MariaDB under
NO_BACKSLASH_ESCAPES, a\in a pattern escapes the character after it instead of matching a backslash: the patternC:\dirmatchesC:dir. Patterns without\, PostgreSQL and MySQL/MariaDB in their default mode are unchanged. - A pattern that ends in an unpaired
\throwsInvalidArgumentExceptionbefore SQL instead of a result that differs by database.
Upgrade
composer update solophp/repositorySee LIKE patterns, the changelog and the full diff since 1.0.0.