-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CSHARP-5453: Add builder for CSFLE schemas #1631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
papafe
wants to merge
39
commits into
mongodb:main
Choose a base branch
from
papafe:csharp5453
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
db1dea7
CSHARP-5453: Improve field encryption usability with attributes/API
papafe cee7a93
Small corrections
papafe 7d1c109
Fixed stub
papafe 87b1c2f
Small fix
papafe ee898d3
Various improvements
papafe a3a06a7
Conversion to records
papafe e599cc0
Various improvements
papafe 400b8b0
Fixed API
papafe 0a32d51
Small comment
papafe c3bfde4
Fix to naming
papafe dd1aeaf
Several improvements
papafe f21b87a
Removed unused
papafe f88465c
First improvement
papafe 33fcbeb
Removed old things
papafe 6a265c2
Improvements
papafe c37c6bb
Some simplifications
papafe 6f1b2a3
Simplified
papafe 4942f97
Improved API
papafe 93f46f9
Small fix
papafe 670c663
Fixing schema builder
papafe 517db94
Various improvements plus fixed tests
papafe 8f10903
Small fix
papafe ef5faa9
Added first basic test
papafe 601169e
Corrections plus more tests
papafe 4ddfdf8
Corrected order
papafe f31c705
Improved tests
papafe 0069760
Added exceptions and improved testing
papafe bd88e8b
Moved builder to encryption project and removed CsfleEncryptionEnum (…
papafe 20379df
Put bsontypes to be nullable and removed unsupported bsonTypes
papafe a8390d3
Corrected test naming
papafe d30739d
Fixed API for overloads
papafe fa3143c
Added exception for empty schema
papafe 134622e
Added docs
papafe 6098c29
Small fix
papafe 7a4f46a
Fix
papafe a25ad56
Removed unnecessary
papafe 84ddfbd
Name fix
papafe eca0ace
Removed unnecessaty
papafe b6ef4d2
Added common method BsonType --> string and removed unnecessary files.
papafe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* Copyright 2010-present MongoDB Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace MongoDB.Bson.Serialization | ||
{ | ||
/// <summary> | ||
/// A static class containing extension methods for <see cref="BsonType"/>. | ||
/// </summary> | ||
public static class BsonTypeExtensions | ||
{ | ||
/// <summary> | ||
/// Maps a <see cref="BsonType"/> to its corresponding string representation. | ||
/// </summary> | ||
/// <param name="type">The input type to map.</param> | ||
public static string ToStringRepresentation(this BsonType type) | ||
{ | ||
return type switch | ||
{ | ||
BsonType.Array => "array", | ||
BsonType.Binary => "binData", | ||
BsonType.Boolean => "bool", | ||
BsonType.DateTime => "date", | ||
BsonType.Decimal128 => "decimal", | ||
BsonType.Document => "object", | ||
BsonType.Double => "double", | ||
BsonType.Int32 => "int", | ||
BsonType.Int64 => "long", | ||
BsonType.JavaScript => "javascript", | ||
BsonType.JavaScriptWithScope => "javascriptWithScope", | ||
BsonType.MaxKey => "maxKey", | ||
BsonType.MinKey => "minKey", | ||
BsonType.Null => "null", | ||
BsonType.ObjectId => "objectId", | ||
BsonType.RegularExpression => "regex", | ||
BsonType.String => "string", | ||
BsonType.Symbol => "symbol", | ||
BsonType.Timestamp => "timestamp", | ||
BsonType.Undefined => "undefined", | ||
_ => throw new ArgumentException($"Unexpected BSON type: {type}.", nameof(type)) | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rstam this is the new method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we should add this to the public API just so EF Core can use it. EF Core can easily duplicate this very small method.
Unless there is a clear scenario where a USER would find this useful, I wouldn't add it to the public API.
Definitely a good idea to centralize this conversion in an
internal
method for our own consumption.If we do make this public I suggest it be done as a separate JIRA ticket so that users can see it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a useful method with a clear and defined purpose and limited API surface. If I need it in the EF provider chances are other people need it too and probably also had to reproduce it. They'd need it right now if they're doing their own queryable encryption or CSFLE work and are trying to leverage BsonType in order to generate the schema.