Skip to content

SWIFT-325 BSON init int64 inconsistency. (Not a bug) #89

Open
@icyield

Description

@icyield

When initing a BSON from a literal it is an int64 by default, but is easy to change (.int32(5)). However when using JSON the "default" type is int32.

Is there a method to force JSON to give int64 as the default type for small value ints?

We have

/// Initialize a BSON from an integer. On 64-bit systems, this will result in an .int64. On 32-bit systems,
/// this will result in an .int32.
public init(integerLiteral value: Int) {
self.init(value)
}

But for JSON we have
// Spec requires that we try int32, try int64, then try double for decoding numbers
if let int32 = try Int32(fromExtJSON: json, keyPath: keyPath) {
self = int32.bson
return
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    tracked-in-jiraTicket filed in Mongo's Jira system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions