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

Enumerate sort.field with '*' #365

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

yhoonkim
Copy link
Contributor

I added autoAddCountOnSort on config to enable to enumerate sort.field with '*'.

@yhoonkim yhoonkim self-assigned this Mar 29, 2017
@yhoonkim yhoonkim requested a review from kanitw March 29, 2017 05:06
src/wildcard.ts Outdated
@@ -279,6 +279,9 @@ export const DEFAULT_ENUM_INDEX: EnumIndex = {
export function getDefaultEnumValues(prop: Property, schema: Schema, opt: QueryConfig): any[] {
if (prop === 'field' || (isEncodingNestedProp(prop) && prop.parent === 'sort' && prop.child === 'field')) {
// For field, by default enumerate all fields
if ((isEncodingNestedProp(prop) && prop.parent === 'sort' && prop.child === 'field') && opt.autoAddCountOnSort){
Copy link
Member

@kanitw kanitw Mar 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The insertion here is a bit weird because it makes the following comment outdated:

For field, by default enumerate all fields

The name autoAddCountOnSort is a bit misleading since you are not really adding count here, you are adding '*'.

I'd say remove the misleading autoAddCountOnSort config and just keep this logic here (it seems generally useful thus shouldn't require a config), but add proper comment describing why you need to add '*' to sort.field (to support count).

@@ -375,6 +375,18 @@ export const FIELD_CONSTRAINTS: EncodingConstraintModel<FieldQuery>[] = [
}
return true;
}
},{
name: 'onlyCountWithAutoCountFieldOnSort',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't related to autoCount.

onlyUseCountWithAsteriskSortField?

allowWildcardForProperties: false,
strict: true,
satisfy: (fieldQ: FieldQuery, _: Schema, __: PropIndex<Wildcard<any>>, ___: QueryConfig) => {
if (fieldQ.sort && !!(fieldQ.sort as SortField).field) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't hack using as SortField -- do proper type guard using isSortField in VL's sort.ts

@@ -492,6 +492,25 @@ describe('constraints/encoding', () => {
});
});

describe('onlyCountWithAutoCountFieldOnSort', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename

@kanitw
Copy link
Member

kanitw commented Mar 29, 2017

  • Improve test coverage

@kanitw
Copy link
Member

kanitw commented Apr 11, 2017

There are some conflicts, possibly because encoding.ts and its test file have been splitted.

@yhoonkim
Copy link
Contributor Author

@kanitw
Current master branch fails on testing.
TypeError: Cannot read property 'forEach' of undefined
I'll merge it after master branch resolves this error.

@kanitw
Copy link
Member

kanitw commented May 16, 2017

@yhoonkim Can you rebase this when you have time?

@yhoonkim
Copy link
Contributor Author

@kanitw I rebased this branch but still tests fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants