Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

moped 1.5 doesn't work correctly on big-endian systems #390

Description

@bryanpkc

lib/moped/bson.rb specifies the ways in which BSON fields are packed, but they currently use native endianness, which leads to errors on a big-endian system because the encoding for BSON fields are in little-endian byte order. The following patch fixes the problem.

diff --git a/lib/moped/bson.rb b/lib/moped/bson.rb
index 2136aa2..5aca1c1 100644
--- a/lib/moped/bson.rb
+++ b/lib/moped/bson.rb
@@ -16,8 +16,8 @@ module Moped

     EOD = NULL_BYTE = "\u0000".freeze

-    INT32_PACK = 'l'.freeze
-    INT64_PACK = 'q'.freeze
+    INT32_PACK = "l<".freeze
+    INT64_PACK = 'q<'.freeze
     FLOAT_PACK = 'E'.freeze

     START_LENGTH = [0].pack(INT32_PACK).freeze

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions