Skip to content

Commit

Permalink
test: add test for setting array default value to null re: #6691
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jul 4, 2024
1 parent 02afe2b commit b2f7ee4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3198,6 +3198,23 @@ describe('document', function() {
assert.ok(!('names' in doc));
});

it('can set array default to null (gh-14717)', async function() {
const schema = new Schema({
names: {
type: [String],
default: null
}
});

const Model = db.model('Test', schema);
const m = new Model();
assert.strictEqual(m.names, null);
await m.save();

const doc = await Model.collection.findOne({ _id: m._id });
assert.strictEqual(doc.names, null);
});

it('validation works when setting array index (gh-3816)', async function() {
const mySchema = new mongoose.Schema({
items: [
Expand Down

0 comments on commit b2f7ee4

Please sign in to comment.