Sequelize - FIX/SubQuery and Raw (#16657)

* Sequelize - FIX/SubQuery and Raw 

In the `FindOptions` there is an optional property missing from the definition file that allows you to turn on and off sub queries with nested associations

Documentation of functionality:
https://github.com/sequelize/sequelize/issues/1756

Please fill in this template.

- [ ] Use a meaningful title for the pull request. Include the name of the package modified.
- [ ] Test the change in your own code. (Compile and run.)
- [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request).
- [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes).
- [ ] Run `npm run lint package-name` (or `tsc` if no `tslint.json` is present).

Select one of these and delete the others:

If adding a new definition:
- [ ] The package does not provide its own types, and you can not add them.
- [ ] If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
- [ ] Create it with `dts-gen --dt`, not by basing it on an existing project.
- [ ] `tslint.json` should be present, and `tsconfig.json` should have `noImplicitAny`, `noImplicitThis`, and `strictNullChecks` set to `true`.

If changing an existing definition:
- [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <<url here>>
- [ ] Increase the version number in the header if appropriate.
- [ ] If you are making substantial changes, consider adding a `tslint.json` containing `{ "extends": "../tslint.json" }`.

If removing a declaration:
- [ ] If a package was never on DefinitelyTyped, you don't need to do anything. (If you wrote a package and provided types, you don't need to register it with us.)
- [ ] Delete the package's directory.
- [ ] Add it to `notNeededPackages.json`.

* Adding test
This commit is contained in:
John Pinkster
2017-06-02 10:21:01 -04:00
committed by Andy
parent 2264bdbaa1
commit ad99b8e217
2 changed files with 10 additions and 4 deletions

View File

@@ -3171,7 +3171,6 @@ declare namespace sequelize {
* be returned. Only applies if `options.paranoid` is true for the model.
*/
paranoid?: boolean;
}
/**
@@ -3244,13 +3243,13 @@ declare namespace sequelize {
raw?: boolean;
/**
* having ?!?
* having ?!?
*/
having?: WhereOptions;
/**
* Group by. It is not mentioned in sequelize's JSDoc, but mentioned in docs.
* https://github.com/sequelize/sequelize/blob/master/docs/docs/models-usage.md#user-content-manipulating-the-dataset-with-limit-offset-order-and-group
* Group by. It is not mentioned in sequelize's JSDoc, but mentioned in docs.
* https://github.com/sequelize/sequelize/blob/master/docs/docs/models-usage.md#user-content-manipulating-the-dataset-with-limit-offset-order-and-group
*/
group?: string | string[] | Object;
@@ -3259,6 +3258,11 @@ declare namespace sequelize {
* Apply DISTINCT(col) for FindAndCount(all)
*/
distinct?: boolean;
/**
* Prevents a subquery on the main table when using include
*/
subQuery?: boolean;
}
/**

View File

@@ -913,6 +913,8 @@ User.findAll( { attributes: [[s.fn('count', Sequelize.col('*')), 'count']], grou
User.findAll( { attributes: [s.cast(s.fn('count', Sequelize.col('*')), 'INTEGER')] });
User.findAll( { attributes: [[s.cast(s.fn('count', Sequelize.col('*')), 'INTEGER'), 'count']] });
User.findAll( { where : s.fn('count', [0, 10]) } );
User.findAll( { subQuery: false, include : [User], order : [[User, User, 'numYears', 'c']] } );
User.findById( 'a string' );