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 = (() => {
37
37
38
38
let targetModel = this . Model ;
39
39
40
- if ( this . scoped ) {
40
+ if ( this . scoped !== undefined ) {
41
41
// Adds scope info to 'this' context
42
42
targetModel = Object . create ( targetModel ) ;
43
43
targetModel . $scope = this . $scope ;
@@ -49,9 +49,9 @@ export const Model: any = (() => {
49
49
}
50
50
} ) ;
51
51
52
- // 'scope' need to be called with 'this'context
52
+ // 'scope' and 'unscoped' need to be called with 'this' context
53
53
// instead of 'this.Model' context
54
- _Model [ 'scope' ] = function ( ...args : any [ ] ) : any {
54
+ _Model [ 'scope' ] = _Model [ 'unscoped' ] = function ( ...args : any [ ] ) : any {
55
55
return SeqModelProto . scope . call ( this , ...args ) ;
56
56
} ;
57
57
Original file line number Diff line number Diff line change @@ -72,6 +72,16 @@ describe('scopes', () => {
72
72
} )
73
73
) ;
74
74
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
+
75
85
describe ( 'with include options' , ( ) => {
76
86
77
87
it ( 'should consider scopes and additional included model (object)' , ( ) =>
@@ -104,6 +114,32 @@ describe('scopes', () => {
104
114
) . not . to . be . rejected
105
115
) ;
106
116
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
+
107
143
} ) ;
108
144
109
145
} ) ;
You can’t perform that action at this time.
0 commit comments