[SERVER-29588] Create a $_internalSchemaUniqueItems MatchExpression Created: 12/Jun/17  Updated: 30/Oct/23  Resolved: 07/Jul/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 3.5.10

Type: Task Priority: Major - P3
Reporter: Kyle Suarez Assignee: Kyle Suarez
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Query 2017-07-10, Query 2017-07-31
Participants:

 Description   
Proposed Syntax

{ <field>: { $_internalSchemaUniqueItems: true } }

The match expression takes a single value: the boolean true. It matches an array whose elements are all unique, according to our definition of equality.

With this, we could implement JSON Schema's "uniqueItems" validation keyword by compiling it to the MatchExpression

{$or: [{<field>: {$not: {$type: "array"}}}, {<field>: {$uniqueItems: true}}]}



 Comments   
Comment by Githook User [ 07/Jul/17 ]

Author:

{u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'kyle.suarez@mongodb.com'}

Message: SERVER-29588 create an $_internalSchemaUniqueItems MatchExpression
Branch: master
https://github.com/mongodb/mongo/commit/306e5376eaa4d48c6fc0ae1afb9a61e9eaffd498

Comment by Kyle Suarez [ 16/Jun/17 ]

Interesting question: should we reject

{$schemaUniqueItems: false}

? It would be a no-op.

Generated at Thu Feb 08 04:21:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.