[SERVER-29581] Create $_internalSchemaMinLength and $_internalSchemaMaxLength MatchExpressions Created: 12/Jun/17  Updated: 30/Oct/23  Resolved: 14/Jul/17

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

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

Issue Links:
Related
related to SERVER-30467 Extend $_internalSchemaMinLength and ... Closed
Backwards Compatibility: Fully Compatible
Sprint: Query 2017-07-10, Query 2017-07-31
Participants:

 Description   

Create a $_internalSchemaMinLength MatchExpression, which takes a positive integer. It matches string fields whose length are at least the specified value:

{"path.to.match": {$_internalSchemaMinLength: <integer>}}

$_internalSchemaMaxLength works similarly for maximum length.

{"path.to.match": {$_internalSchemaMaxLength: <integer>}}

Then, we can use these expression to emit MatchExpressions for the JSON Schema "minLength" and "maxLength" keywords.



 Comments   
Comment by Kyle Suarez [ 01/Aug/17 ]

Cool, I filed SERVER-30467.

Comment by David Storch [ 01/Aug/17 ]

kyle.suarez, I'd say a new ticket given that this work is already in master.

Comment by Kyle Suarez [ 01/Aug/17 ]

I agree, based on my reading of RFC 4627 §1:

A string is a sequence of zero or more Unicode characters.

and JSON Schema Draft 04 §5.2.1.2:

The length of a string instance is defined as the number of its characters as defined by RFC 4627.

I can file a ticket for this or reopen this one; whatever is your preference.

Comment by David Storch [ 01/Aug/17 ]

kyle.suarez, my reading of RFC 4627 is that JSON strings are unicode. Therefore, I think these match expressions should probably count code points rather than bytes in the UTF-8 encoding. Does that match your understanding of the JSON Schema spec? At first glance it wasn't completely clear to me.

Comment by Kyle Suarez [ 01/Aug/17 ]

This code was implemented using BSONElement::valuestrlen(), which does a simple counting of the number of bytes in a string. If we need to support multibyte characters, we'll need a slight tweak.

Comment by Githook User [ 14/Jul/17 ]

Author:

{u'name': u'Natalia Jacobowitz', u'email': u'nataliajacobowitz@MacBook-Pro-107.local'}

Message: SERVER-29581 Create $_internalSchemaMinLength and $_internalSchemaMaxLength MatchExpressions
Branch: master
https://github.com/mongodb/mongo/commit/baeddbb37594ebff1d5d6d45e1988d73a9e275a4

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