Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packages[core-data]: Change "include" type in getQueryParts #40570

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/core-data/src/queried-data/get-query-parts.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ export function getQueryParts( query ) {

// Two requests with different include values cannot have same results.
if ( key === 'include' ) {
if ( typeof value === 'number' ) {
value = value.toString();
}
mauriac marked this conversation as resolved.
Show resolved Hide resolved
parts.include = (
getNormalizedCommaSeparable( value ) ?? []
).map( Number );
Expand Down
4 changes: 4 additions & 0 deletions packages/core-data/src/queried-data/test/get-query-parts.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ describe( 'getQueryParts', () => {
} );

it( 'parses out `include` ID filtering', () => {
const first = getQueryParts( { include: '1' } );
const second = getQueryParts( { include: 1 } );
const parts = getQueryParts( { include: [ 1 ] } );

expect( first ).toEqual( second );
expect( second ).toEqual( parts );
expect( parts ).toEqual( {
context: 'default',
page: 1,
Expand Down