[CSHARP-1622] Add $cpLength and $cpSubstr expressions which work via code points Created: 06/Apr/16  Updated: 27/May/22  Resolved: 11/Sep/16

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: None
Fix Version/s: 2.4

Type: New Feature Priority: Major - P3
Reporter: Rathi Gnanasekaran Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-22580 Add $cpLength and $cpSubstr expressio... Closed
is depended on by DRIVERS-297 Aggregation Framework Support for 3.4 Closed
Epic Link: MongoDB 3.4
Server Compat: 3.3

 Description   

Syntax

{$substrBytes: <expression>}
{$substrCP: <expression>}

Examples

Input

{_id: 0, string: "ελληνικά"}

Pipeline

db.coll.aggregate([{
    $project: {
        byteSubstr: {$substrBytes: ["$string", 0, 4]},
        cpSubstr: {$substrCP: ["$string", 0, 4]}
    }
}])

Output

{_id: 0, byteSubstr: "ελ", cpSubstr: "ελλη"}

Additional Notes

  • Will not add any new query functionality to work with strings.
  • $substrBytes will error if it starts or ends in the middle of a code point.
  • $substrCP will error on any input that is detected to be invalid UTF-8.


 Comments   
Comment by Githook User [ 29/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1622: Fixed minor issue that was causing some tests to fail.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/8a7bedc72fca6c895ee34ae3a4ad6cfc04c9a9b1

Comment by Githook User [ 29/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1622: added support for $substrCP.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/01b378f52980a0a7b042efb1b96235c497b045a9

Comment by Githook User [ 24/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1622: Fixed minor issue that was causing some tests to fail.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/8a7bedc72fca6c895ee34ae3a4ad6cfc04c9a9b1

Comment by Githook User [ 24/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1622: added support for $substrCP.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/01b378f52980a0a7b042efb1b96235c497b045a9

Comment by Githook User [ 21/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1622: Fixed minor issue that was causing some tests to fail.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/feea8a0961acffc098684fa06b37182d49d38035

Comment by Githook User [ 21/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1622: added support for $substrCP.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/e18fd5aa39f0523aa27304a34ff61e252af91005

Comment by Githook User [ 16/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1622: Fixed minor issue that was causing some tests to fail.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/1d0d6f3ff04e5e9265606d788cca89d97065f620

Comment by Githook User [ 16/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1622: added support for $substrCP.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/407dfc0fc2d1228ae32c506a5f1ddc20811ab5fe

Comment by Githook User [ 11/Sep/16 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}

Message: CSHARP-1622: Fixed minor issue that was causing some tests to fail.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/2a5e08cd543400e367e918d31f713a7431c4d7d4

Comment by Githook User [ 09/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1622: added support for $substrCP.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/c585eb68d2d06fc3b13c43c97cd875df4ac70567

Comment by Craig Wilson [ 23/Aug/16 ]

There isn't currently anything we can do here. We already support $substr, which, while inaccurate for multi-byte characters, can't be changed because it is backwards breaking and we can't do server version checking.

Generated at Wed Feb 07 21:40:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.