[JAVA-3996] Remove restrictions on using field names with dots and dollars Created: 04/Feb/21  Updated: 28/Oct/23  Resolved: 09/Jun/21

Status: Closed
Project: Java Driver
Component/s: Write Operations
Affects Version/s: None
Fix Version/s: 4.3.0

Type: New Feature Priority: Major - P3
Reporter: Backlog - Core Eng Program Management Team Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Issue split
Related
is related to JAVA-3452 java.lang.IllegalArgumentException: I... Closed
Server Compat: 5.0
Quarter: FY22Q2
Documentation Changes: Needed

 Description   

Summary

Remove any validation code in drivers that prevents storing data with "$" and "." in key names. Without an MQL-wide escaping mechanism, the server will provide users with some tools that will allow them to express queries over such data. Drivers must document how to express such queries.

Motivation

Many data sources, including MongoDB's own system.profile, contain information stored with dots or dollars in the key names. Any user who wishes to operate on change stream notifications, the schema of the config database, the system.profile collection, or MongoDB structured log data may need to express queries over key names with dot and dollar. Some users may also ingest unsanitized data from outside sources, and currently would be forced to implement their own escaping before storing the data in order to ensure it is queryable. Many users also wish to use well-known formats that involve dots as key names, such as URLs or IP addresses.

MQL has limited facilities for expressing queries over such data. Historically, both the driver and the server have rejected attempts to insert data of this form in order to prevent a situation where users have data over which they cannot easily express queries. This is a common source of complaint from the user



 Comments   
Comment by Jeffrey Yemin [ 28/Jun/21 ]

esha.bhargava looks like the spec tests changed after this ticket was already closed. Can you generate a new JAVA ticket to track this?

Comment by Jeremy Mikola [ 25/Jun/21 ]

FYI: DRIVERS-1237 was revised to sync spec tests to mongodb/specifications@fc21cb7 (previously mongodb/specifications@a124e21) to remove an insertedCount assertion for the result of an insertOne operation. Please update your tests accordingly and remove any work-arounds you may have had to make in your test runner.

Comment by Githook User [ 09/Jun/21 ]

Author:

{'name': 'Jeff Yemin', 'email': 'jeff.yemin@mongodb.com', 'username': 'jyemin'}

Message: Remove most field name validation (#725)

The driver no longer restricts field names containing ".".
The driver no longer restricts field names starting with "$", except for
top-level fields in documents being saved via replaceOne, findOneAndReplace,
and ReplaceOneModel in bulkWrite. This is to ensure that applications don't
accidentally use replace when they meant to use update.

JAVA-3996
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/0fd3b04c8669d24c2349feb17cc1d66f49b07083

Generated at Thu Feb 08 09:00:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.