Skip to content

Conversation

@raymondfeng
Copy link
Contributor

@raymondfeng raymondfeng commented Dec 11, 2017

Description

The PR adds execute() and builders for our Filter/Where objects.

Related issues

  • connect to <link_to_referenced_issue>

Checklist

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

Good work, @raymondfeng! I did not review all new tests and builder methods in detail, but I don't see any major problems beyond the things pointed out below.

At high level, please check why our code coverage is decreased by your changes by -0.3%, I think your tests are missing some important use cases.

* Sorting order for matched entities
*/
order?: Order[];
order?: string[];
Copy link
Member

Choose a reason for hiding this comment

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

I am worried that this change will allow people to accidentally use invalid values for order and the TypeScript compiler will not catch that problem. Can we preserve this type? Unless I am missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are a few issues around this signature:

  1. Order is defined as {[field: string]: Direction}. That means we can have {a: 'ASC', b: 'DESC'}. Do we translate it to ORDER BY A ASC, B DESC? If so, can we avoid Order[]`?

  2. string[] is not very intuitive. I use it internally for now to avoid translation to legacy juggler order format.

  3. The FilterBuilder takes Order for type safety.

Copy link
Member

Choose a reason for hiding this comment

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

I see, I think I got confused about the difference between Order and Direction, as it seems to be the same thing. Maybe Ordering would be a better type name?

In the light of your comment, I am ok to keep the current implementation, but please add a comment explaining why we are using string[] type here and perhaps add a link pointing to our docs where people can learn more about valid values.

}

/**
* A builder for Where object
Copy link
Member

Choose a reason for hiding this comment

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

Please include a short example showing how to use this builder.

}

/**
* A builder for Filter
Copy link
Member

Choose a reason for hiding this comment

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

Please include a short example showing how to use this builder.

class AppWithRepoMixin extends RepositoryMixin(Application) {}

class NoteRepo {
class NoteRepo implements Repository<any> {
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be Repository<Note>, or at least Repository<Entity>. Thoughts?

@raymondfeng raymondfeng force-pushed the add-builders-and-execute branch from b586c49 to 23a8ac7 Compare December 12, 2017 15:47
@raymondfeng raymondfeng force-pushed the add-builders-and-execute branch 7 times, most recently from 40abe76 to 796ff03 Compare December 12, 2017 18:38
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

I cannot tell what you changed in the tests (because there is only a single commit), but since the code coverage is going up now, I am happy 😄

I found few minor things to improve before this is landed, see below.

Other than that, the patch LGTM.

* `and`, `or`, and other operators.
*
* @example
* ```
Copy link
Member

Choose a reason for hiding this comment

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

Please add ts or js after the last back-tick to enable syntax highlighting.

* @example
* ```
* const whereBuilder = new WhereBuilder();
* const where = whereBuilder
Copy link
Member

Choose a reason for hiding this comment

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

Please keep the indentation consistent.

* `fields`, `order`, `where`, `limit`, `offset`, and `include`.
*
* @example
* ```
Copy link
Member

Choose a reason for hiding this comment

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

Please add ts or js after the last back-tick to enable syntax highlighting.

@raymondfeng raymondfeng force-pushed the add-builders-and-execute branch from 796ff03 to be5aec4 Compare December 12, 2017 19:00
Add builders with fleunt APIs to build Filter and Where objects
Add execute method to Repository interfaces
@raymondfeng raymondfeng force-pushed the add-builders-and-execute branch from be5aec4 to 842dea8 Compare December 12, 2017 19:07
@raymondfeng raymondfeng changed the title [WIP] Add builders and execute Add builders and execute for repository Dec 12, 2017
@raymondfeng raymondfeng merged commit 89eaf5f into master Dec 12, 2017
@raymondfeng raymondfeng deleted the add-builders-and-execute branch December 14, 2017 19:38
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.

3 participants