@@ -4171,14 +4171,22 @@ describe('Query', function() {
4171
4171
assert . equal ( q . op , 'findOneAndReplace' ) ;
4172
4172
} ) ;
4173
4173
4174
- it ( 'allows deselecting discriminator key (gh-13679)' , async function ( ) {
4175
- const testSchema = new Schema ( { name : String } ) ;
4174
+ it ( 'allows deselecting discriminator key (gh-13760) (gh- 13679)' , async function ( ) {
4175
+ const testSchema = new Schema ( { name : String , age : Number } ) ;
4176
4176
const Test = db . model ( 'Test' , testSchema ) ;
4177
4177
const Test2 = Test . discriminator ( 'Test2' , new Schema ( { test : String } ) ) ;
4178
4178
4179
4179
const { _id } = await Test2 . create ( { name : 'test1' , test : 'test2' } ) ;
4180
4180
const { name, __t } = await Test . findById ( _id ) . select ( { __t : 0 } ) ;
4181
4181
assert . strictEqual ( name , 'test1' ) ;
4182
4182
assert . strictEqual ( __t , undefined ) ;
4183
+
4184
+ let doc = await Test . findById ( _id ) . select ( { __t : 0 , age : 0 } ) ;
4185
+ assert . strictEqual ( doc . name , 'test1' ) ;
4186
+ assert . strictEqual ( doc . __t , undefined ) ;
4187
+
4188
+ doc = await Test . findById ( _id ) . select ( [ '-__t' , '-age' ] ) ;
4189
+ assert . strictEqual ( doc . name , 'test1' ) ;
4190
+ assert . strictEqual ( doc . __t , undefined ) ;
4183
4191
} ) ;
4184
4192
} ) ;
0 commit comments