Create WP_Query in a fluent way
Repo Pollora/Query, read from GitHub 1 min ago. Pollora has not joined Take My Repo.
DECIMAL(10,0) by MySQL and MariaDB, so 1.5 and 1.9 both compared as 2 (and a numeric string such as '1.5' became NUMERIC, which WordPress casts as the integer SIGNED). The builder now sends DECIMAL(precision,scale) with a scale of at least 10 (DECIMAL(30,10)), more when the value has more decimals (up to 30); a list takes the widest scale. ofType('DECIMAL(10,2)') still wins. The detected type of a float is no longer the bare DECIMAL. (#42)containsAll() with the children included (the default) matched nothing as soon as a listed term had a child: WordPress adds the children to the AND list and asks for a post that has all of them. It now sends one IN clause per term joined with AND (a post with each term or one of its children),; excludeChildren() / onlyParent() still send the single AND clause. (#42)TermQuery::count() returned 0 the first time a count was asked, until WordPress had cached it: WP_Term_Query only stores a count in its terms property when it comes from its cache, and the builder read it there. It now uses the value query() returns.tests/Integration, composer test:integration) that runs the builders against a real WordPress and database. It is kept out of the default test run and out of the Composer archive.pollora/wordpress-args 2.0 (^1.1 || ^2.0), which only raises its PHP requirement to 8.3.tagSlugAnd() is documented as taking slugs (array<string>), SubQuery declares get(), the date builder's array shapes match what it returns. No runtime change.metaQuery(), dateQuery() and taxQuery() share the protected mergeSubQuery() (returns the merged query) in place of addSubQuery().Accepts pollora/wordpress-args 2.0 (^1.1 || ^2.0). No code change.
A major release for the PHP requirement: no query changed. Run PHP 8.3 or later.
A major release: Query now covers every query class of WordPress, and several arguments that were wrong or silently ignored are fixed. A few fixes change the results of a query that used to run, so read Upgrading before updating.
TermQuery (WP_Term_Query), UserQuery (WP_User_Query), CommentQuery (WP_Comment_Query), SiteQuery (WP_Site_Query) and NetworkQuery (WP_Network_Query). Every documented argument is covered.first(), ids(), count() and exists(), which run on a copy of the builder and leave it untouched. TermQuery adds names() and slugs(), UserQuery adds pluck(). See Getting results.PostQuery arguments: pageId(), pagename(), title(), menuOrder(); the date fields year(), month(), day(), hour(), minute(), second(), week() and yearMonth(); the top-level meta arguments metaKey(), metaValue(), metaCompare(), metaType(), metaCompareKey() and metaTypeKey(); orderByMeta(); exactSearch(), searchSentence() and searchColumns(); noFoundRows(), suppressFilters() and lazyLoadTermMeta().regexp(), notRegexp(), rlike(), keyCompare() and keyType().containsAll() (operator => 'AND').registered(), and inclusive() on a single clause.Query::tax(), next to Query::meta() and Query::date().docs/, with a page per query class. Its examples are run by the test suite, and CI fails when one no longer matches the code.where() followed by orWhere() is grouped like Eloquent. where(a)->where(b)->orWhere(c) is (a AND b) OR c; it used to turn the whole group into a OR b OR c.DateQuery::inclusive() works. It was written where WordPress does not read it, so it had no effect; it is now written on each date clause.'2022-01-01' gave hour => 12, '… 15:10:00' gave hour => 3). The parts of a converted date are now integers.QueryException instead of being silently ignored: fields(), userPermission() and the direction of orderBy().date() without a column no longer sends one, so WordPress uses the default of the queried table (post_date, user_registered, comment_date, registered).TermQuery returns empty terms (hide_empty => false) and SiteQuery has no cap of 100 sites (number => 0). PostQuery keeps post_type => 'any'. CommentQuery keeps WordPress' own defaults on purpose (no spam, no trash). See Concepts.DateQueryBuilder::within() always threw a TypeError.var_export printed to the output when a date string was converted.before() or after() threw a TypeError.categoryAnd() sent category_and, which WordPress ignores; it now sends category__and.postType() did not accept an array.orderBy() with an array, and inRandomOrder() followed by orderBy() or latest(), threw a TypeError.ofType() was ignored, and the type of a list was detected from its first value only (between(1, 50) was BINARY, in([]) raised a warning). One type now fits every value.metaQuery(), taxQuery() or dateQuery() twice repeated the clauses of the first call.initQuery(), query() and genericQuery() methods of the query classes. They came from an internal trait by accident and were not documented.Full changelog: 1.0.3...2.0.0
Full Changelog: 1.0.2...1.0.3