Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: orlandos-nl/BSON
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8.0.5
Choose a base ref
...
head repository: orlandos-nl/BSON
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master/8.0
Choose a head ref
  • 19 commits
  • 36 files changed
  • 3 contributors

Commits on Dec 17, 2022

  1. Add docs

    Joannis committed Dec 17, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    MasWho Mason Hu
    Copy the full SHA
    188419b View commit details

Commits on Jan 11, 2023

  1. Update ObjectId.swift

    Andrewangeta authored Jan 11, 2023
    Copy the full SHA
    98fabf3 View commit details

Commits on Jan 12, 2023

  1. Merge pull request #73 from orlandos-nl/identifiable-conformance

    Make `ObjectId` conform to `Identifiable`
    Joannis authored Jan 12, 2023
    Copy the full SHA
    d4582d8 View commit details
  2. Start developing Decimal128

    Joannis committed Jan 12, 2023
    Copy the full SHA
    1e98bdf View commit details

Commits on Feb 7, 2023

  1. Copy the full SHA
    6d5e215 View commit details
  2. Merge pull request #76 from gwynne/fix-superDecoder-8.x

    Add missing superDecoder() and superDecoder(forKey:) for BSONDecoder
    Joannis authored Feb 7, 2023
    Copy the full SHA
    e24ce41 View commit details

Commits on Mar 5, 2023

  1. Allow Date to be decoded from a Double

    # Conflicts:
    #	Sources/BSON/Types/Primitives.swift
    Joannis committed Mar 5, 2023
    Copy the full SHA
    3585aa7 View commit details

Commits on Mar 9, 2023

  1. Copy the full SHA
    1a3999c View commit details

Commits on Mar 13, 2023

  1. Copy the full SHA
    ad4a3ec View commit details
  2. Merge pull request #78 from orlandos-nl/feature/faster-equatable

    Faster Document equation
    Joannis authored Mar 13, 2023
    Copy the full SHA
    e28af5a View commit details
  3. Copy the full SHA
    4c6ad91 View commit details
  4. Copy the full SHA
    8b54dd0 View commit details
  5. Merge pull request #77 from orlandos-nl/feature/jo-fast-bsondecoder

    Implement a simpler but faster BSONDecoder for use by MongoKitten
    Joannis authored Mar 13, 2023
    Copy the full SHA
    6157fa9 View commit details

Commits on Mar 15, 2023

  1. Copy the full SHA
    101726a View commit details
  2. Copy the full SHA
    fca6470 View commit details
  3. Fix a crash in BSON that could happen when converting a Double into a…

    …n Int of your choosing with the Double being too large
    Joannis committed Mar 15, 2023
    Copy the full SHA
    3ca41d3 View commit details
  4. Copy the full SHA
    6056eae View commit details

Commits on Apr 2, 2023

  1. Bump NIO minor

    Joannis committed Apr 2, 2023
    Copy the full SHA
    944dfb3 View commit details

Commits on Sep 3, 2023

  1. Add repository scaffolding

    Joannis committed Sep 3, 2023
    Copy the full SHA
    0fe2f27 View commit details
Showing with 1,589 additions and 169 deletions.
  1. +17 −0 .github/CONTRIBUTING.md
  2. +1 −0 .github/FUNDING.yml
  3. +25 −0 .github/ISSUE_TEMPLATE/bug_report.md
  4. +5 −0 .github/ISSUE_TEMPLATE/config.yml
  5. +20 −0 .github/ISSUE_TEMPLATE/feature_request.md
  6. +10 −0 .github/ISSUE_TEMPLATE/question.md
  7. +19 −0 .github/PULL_REQUEST_TEMPLATE.md
  8. +34 −0 .github/workflows/codeql.yml
  9. +28 −0 .github/workflows/swift.yml
  10. +4 −3 Package.swift
  11. +23 −1 Sources/BSON/Codable/Decoding/BSONDecoder.swift
  12. +2 −2 Sources/BSON/Codable/Decoding/BSONDecoderSettings.swift
  13. +832 −0 Sources/BSON/Codable/Decoding/Fast/FastBSONDecoder.swift
  14. +9 −3 Sources/BSON/Codable/Decoding/KeyedBSONDecodingContainer.swift
  15. +25 −13 Sources/BSON/Document/Document+Array.swift
  16. +13 −5 Sources/BSON/Document/Document+Cache.swift
  17. +5 −1 Sources/BSON/Document/Document+Collection.swift
  18. +3 −2 Sources/BSON/Document/Document+Dictionary.swift
  19. +165 −18 Sources/BSON/Document/Document+Equatable.swift
  20. +1 −0 Sources/BSON/Document/Document+Helpers.swift
  21. +28 −15 Sources/BSON/Document/Document+Mutations.swift
  22. +2 −0 Sources/BSON/Document/Document+Serialization.swift
  23. +35 −27 Sources/BSON/Document/Document+Subscripts.swift
  24. +3 −3 Sources/BSON/Document/Document+Validation.swift
  25. +1 −1 Sources/BSON/Document/Document.swift
  26. +5 −0 Sources/BSON/Document/DocumentSlice.swift
  27. +26 −2 Sources/BSON/Helpers/ByteBuffer+Helpers.swift
  28. +15 −0 Sources/BSON/Types/Binary.swift
  29. +23 −5 Sources/BSON/Types/Decimal128.swift
  30. +2 −0 Sources/BSON/Types/JavaScript.swift
  31. +1 −1 Sources/BSON/Types/Null.swift
  32. +12 −3 Sources/BSON/Types/ObjectId.swift
  33. +69 −51 Sources/BSON/Types/Primitives.swift
  34. +1 −0 Sources/BSON/Types/Timestamp.swift
  35. +14 −0 Tests/BSONTests/BSONEncoderTests.swift
  36. +111 −13 Tests/BSONTests/BSONPublicTests.swift
17 changes: 17 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Contributing to MongoKitten

We welcome contributions, and request you follow these guidelines.

- [Raising issues](#raising-issues)

## Raising issues

Please raise any bug reports on the issue tracker. Be sure to
search the list to see if your issue has already been raised.

A good bug report is one that make it easy for us to understand what you were trying to do and what went wrong. Provide as much context as possible so we can try to recreate the issue.

## Coding standards
Please note:

- all PRs must have passing builds for all operating systems.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: joannis
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: Joannis

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Environment:**
- OS: [e.g. macOS Sonoma, Linux or Windows]
- Swift Version: [e.g. 5.9]
- BSON Version [e.g. 8.0]

**Additional context**
Add any other context about the problem here.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Community Support (Discord)
url: https://discord.gg/H6799jh
about: Meet with the community here!
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea
title: ''
labels: enhancement, help wanted
assignees: Joannis

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Question
about: Ask for help
title: ''
labels: help wanted, question
assignees: 'joannis'

---


19 changes: 19 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] If applicable, I have updated the documentation accordingly.
- [ ] If applicable, I have added tests to cover my changes.
34 changes: 34 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "CodeQL"

on:
push:
branches: [ "master/7.0" ]
pull_request:
branches: [ "master/7.0" ]

jobs:
analyze:
name: Analyze
runs-on: macos-latest
permissions:
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'swift' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Build
run: swift build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
28 changes: 28 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Swift

on:
push:
branches:
- master/7.0
pull_request:
branches:
- master/7.0

jobs:
linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swift-version: ["5.7", "5.8"]
steps:
- name: Check out
uses: actions/checkout@v3

- name: Install Swift
uses: swift-actions/setup-swift@v1
with:
swift-version: ${{ matrix.swift-version }}

- name: Run tests
run: swift test
7 changes: 4 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ let package = Package(
targets: ["BSON"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0")
.package(url: "https://github.com/apple/swift-nio.git", from: "2.46.0")
],
targets: [
.target(
@@ -25,7 +25,8 @@ let package = Package(
),
.testTarget(
name: "BSONTests",
dependencies: ["BSON"])
],
dependencies: ["BSON"]
)
],
swiftLanguageVersions: [.v4_2]
)
24 changes: 23 additions & 1 deletion Sources/BSON/Codable/Decoding/BSONDecoder.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

/// A helper that is able to decode BSON data types into a `Decodable` type
/// A helper that is able to decode BSON data types into a `Decodable` type.
public struct BSONDecoder {
/// The configuration used for decoding
public var settings: BSONDecoderSettings
@@ -102,6 +102,14 @@ extension BSONDecoderSettings.IntegerDecodingStrategy {
}

/// Decodes the `value` without key to an integer of type `I` using the current strategy
@_specialize(where I == UInt8)
@_specialize(where I == Int8)
@_specialize(where I == UInt16)
@_specialize(where I == Int16)
@_specialize(where I == UInt32)
@_specialize(where I == Int32)
@_specialize(where I == UInt)
@_specialize(where I == Int)
internal func decode(
from decoder: _BSONDecoder,
path: @autoclosure () -> [String]
@@ -130,6 +138,13 @@ extension BSONDecoderSettings.IntegerDecodingStrategy {
case (let int as Int, _):
return try int.convert(to: I.self)
case (let double as Double, .roundingAnyNumber), (let double as Double, .adaptive):
guard
double >= Double(I.min),
double <= Double(I.max)
else {
throw DecodingError.typeMismatch(Double.self, .init(codingPath: [], debugDescription: "The IntegerDecodingStrategy is adaptive, but the Double could not be converted to \(I.self)"))
}

return I(double)
case (let string as String, .adaptive):
guard let int = I(string) else {
@@ -169,6 +184,13 @@ extension BSONDecoderSettings.IntegerDecodingStrategy {
case (.int64, let int as Int), (.adaptive, let int as Int), (.anyInteger, let int as Int), (.roundingAnyNumber, let int as Int):
return try int.convert(to: I.self)
case (.roundingAnyNumber, let double as Double), (.adaptive, let double as Double):
guard
double >= Double(I.min),
double <= Double(I.max)
else {
throw DecodingError.typeMismatch(Double.self, .init(codingPath: [], debugDescription: "The IntegerDecodingStrategy is adaptive, but the Double could not be converted to \(I.self)"))
}

return I(double)
case (.custom(let strategy), _):
guard let value: I = try strategy(key, value) else {
4 changes: 2 additions & 2 deletions Sources/BSON/Codable/Decoding/BSONDecoderSettings.swift
Original file line number Diff line number Diff line change
@@ -158,8 +158,8 @@ public struct BSONDecoderSettings {
/// If `true`, allows decoding ObjectIds from Strings if they're formatted as a 24-character hexString
public var decodeObjectIdFromString: Bool = false

/// If `true`, allows decoding ObjectIds from Strings if they're formatted as a 24-character hexString
public var decodeDateFromTimestamp: Bool = false
/// If `true`, allows decoding Date from a Double (TimeInterval)
public var decodeDateFromTimestamp: Bool = true

/// A strategy that is applied when encountering a request to decode a `Float`
public var floatDecodingStrategy: FloatDecodingStrategy
Loading