Skip to content

Commit

Permalink
fix: remove unscoped fn in src/adapters/sequelize.js (#387)
Browse files Browse the repository at this point in the history
* fix: remove unscoped fn in src/adapters/sequelize.js

* test: 修改 unscoped() 相关单测

* test: 修改 unscoped() 相关单测 again

---------

Co-authored-by: Chen Yangjian <[email protected]>
  • Loading branch information
vagusX and cyjake authored May 11, 2023
1 parent ddcefbc commit eb86ae2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/adapters/sequelize.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class SequelizeBone extends AbstractBone {
*/
static scope<T extends typeof SequelizeBone>(this: T, name?: (string | ((...args: any[]) => SequelizeConditions<T>) | SequelizeConditions<T> | Array<SequelizeConditions<T>>), ...args: any[]): T;

static unscoped(): Spell<typeof SequelizeBone>;
static get unscoped(): Spell<typeof SequelizeBone>;

/**
* @deprecated scope is not recommended to use
Expand Down
4 changes: 0 additions & 4 deletions src/adapters/sequelize.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@ module.exports = function sequelize(Bone) {
return this.scope();
}

static unscoped() {
return this.scope();
}

/**
* @deprecated scope is not recommended to use
* @static
Expand Down
2 changes: 1 addition & 1 deletion test/types/sequelize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ describe('=> sequelize (TypeScript)', function() {
assert.ok(!!(MyPost as any)._scopes.dk);
assert.deepEqual((MyPost as any)._scopes.dk, (Scopped as any)._scope);

const Scopped1 = Scopped.unscoped();
const Scopped1 = Scopped.unscoped;
assert.ok(!(Scopped1 as any)._scope);

});
Expand Down
6 changes: 3 additions & 3 deletions test/unit/adapters/sequelize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1346,9 +1346,9 @@ describe('Model scope', () => {
);
});

it('unscoped() should work', function() {
it('getter unscoped should work', function() {
assert.equal(
MyPost.scope('MHW').unscoped().where({ title: 'New Post' }).toString(),
MyPost.scope('MHW').unscoped.where({ title: 'New Post' }).toString(),
'SELECT * FROM "articles" WHERE "title" = \'New Post\' AND "gmt_deleted" IS NULL'
);
});
Expand Down Expand Up @@ -1409,7 +1409,7 @@ describe('Model scope', () => {
);

assert.equal(
User.unscoped().where({ nickname: 'OldHunter' }).toString(),
User.unscoped.where({ nickname: 'OldHunter' }).toString(),
'SELECT * FROM "users" WHERE "nickname" = \'OldHunter\''
);

Expand Down

0 comments on commit eb86ae2

Please sign in to comment.