File tree Expand file tree Collapse file tree 2 files changed +39
-3
lines changed
Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ export const Model: any = (() => {
3737
3838 let targetModel = this . Model ;
3939
40- if ( this . scoped ) {
40+ if ( this . scoped !== undefined ) {
4141 // Adds scope info to 'this' context
4242 targetModel = Object . create ( targetModel ) ;
4343 targetModel . $scope = this . $scope ;
@@ -49,9 +49,9 @@ export const Model: any = (() => {
4949 }
5050 } ) ;
5151
52- // 'scope' need to be called with 'this'context
52+ // 'scope' and 'unscoped' need to be called with 'this' context
5353 // instead of 'this.Model' context
54- _Model [ 'scope' ] = function ( ...args : any [ ] ) : any {
54+ _Model [ 'scope' ] = _Model [ 'unscoped' ] = function ( ...args : any [ ] ) : any {
5555 return SeqModelProto . scope . call ( this , ...args ) ;
5656 } ;
5757
Original file line number Diff line number Diff line change @@ -72,6 +72,16 @@ describe('scopes', () => {
7272 } )
7373 ) ;
7474
75+ it ( 'should not consider default scope due to unscoped call' , ( ) =>
76+
77+ ShoeWithScopes
78+ . unscoped ( )
79+ . findOne ( )
80+ . then ( shoe => {
81+ expect ( shoe ) . to . have . property ( 'secretKey' ) . which . is . not . null ;
82+ } )
83+ ) ;
84+
7585 describe ( 'with include options' , ( ) => {
7686
7787 it ( 'should consider scopes and additional included model (object)' , ( ) =>
@@ -104,6 +114,32 @@ describe('scopes', () => {
104114 ) . not . to . be . rejected
105115 ) ;
106116
117+ it ( 'should not consider default scope due to unscoped call, but additonal includes (object)' , ( ) =>
118+
119+ ShoeWithScopes
120+ . unscoped ( )
121+ . findOne ( {
122+ include : [ { model : Person } ]
123+ } )
124+ . then ( shoe => {
125+ expect ( shoe ) . to . have . property ( 'secretKey' ) . which . is . not . null ;
126+ expect ( shoe ) . to . have . property ( 'owner' ) . which . is . not . null ;
127+ } )
128+ ) ;
129+
130+ it ( 'should not consider default scope due to unscoped call, but additonal includes (model)' , ( ) =>
131+
132+ ShoeWithScopes
133+ . unscoped ( )
134+ . findOne ( {
135+ include : [ Person ]
136+ } )
137+ . then ( shoe => {
138+ expect ( shoe ) . to . have . property ( 'secretKey' ) . which . is . not . null ;
139+ expect ( shoe ) . to . have . property ( 'owner' ) . which . is . not . null ;
140+ } )
141+ ) ;
142+
107143 } ) ;
108144
109145 } ) ;
You can’t perform that action at this time.
0 commit comments