nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: surrealdb/surrealdb.go
Pull request #193 (2024-12-02 17:58:17)

Disable embedded connections temporarily


Patch:
diff --git a/db.go b/db.go
index ec62e1e..3c4e24d 100644
--- a/db.go
+++ b/db.go
@@ -50,7 +50,8 @@ func New(connectionURL string) (*DB, error) {
 	} else if scheme == "ws" || scheme == "wss" {
 		con = connection.NewWebSocketConnection(newParams)
 	} else if scheme == "memory" || scheme == "mem" || scheme == "surrealkv" {
-		con = connection.NewEmbeddedConnection(newParams)
+		return nil, fmt.Errorf("embedded database not enabled")
+		// con = connection.NewEmbeddedConnection(newParams)
 	} else {
 		return nil, fmt.Errorf("invalid connection url")
 	}
diff --git a/pkg/connection/embedded.go b/pkg/connection/embedded.go
index 052a6c5..fb39ead 100644
--- a/pkg/connection/embedded.go
+++ b/pkg/connection/embedded.go
@@ -1,3 +1,5 @@
+//go:build exclude
+
 package connection
 
 /*


Test patch:
diff --git a/pkg/connection/embedded_test.go b/pkg/connection/embedded_test.go
index d0e8423..8be9f17 100644
--- a/pkg/connection/embedded_test.go
+++ b/pkg/connection/embedded_test.go
@@ -1,3 +1,5 @@
+//go:build exclude
+
 package connection
 
 import (
Repository: surrealdb/surrealdb.go
Pull request #208 (2025-07-10 12:16:48)

Added specific map type to map[string]any for JSON
CBOR decode map to map[any]any which causes the JSON marshaller to fail as it is not a supported type. We can force the map type to map[string]any in the CBOR decoder.

See issue #207 
Found solution: [CBOR](https://github.com/fxamacker/cbor/issues/654)

Questionning:
1. Does surreal support different field key than string?
2. Should we open the decoder options as parameter?


Patch:
diff --git a/pkg/models/cbor.go b/pkg/models/cbor.go
index 1863feb..6e26721 100644
--- a/pkg/models/cbor.go
+++ b/pkg/models/cbor.go
@@ -123,7 +123,8 @@ func getCborEncoder() cbor.EncMode {
 func getCborDecoder() cbor.DecMode {
 	tags := registerCborTags()
 	dm, err := cbor.DecOptions{
-		TimeTagToAny: cbor.TimeTagToTime,
+		TimeTagToAny:   cbor.TimeTagToTime,
+		DefaultMapType: reflect.TypeOf(map[string]any(nil)),
 	}.DecModeWithTags(tags)
 	if err != nil {
 		panic(err)


Test patch:
diff --git a/pkg/models/cbor_test.go b/pkg/models/cbor_test.go
index dd8bf27..f1a5ab6 100644
--- a/pkg/models/cbor_test.go
+++ b/pkg/models/cbor_test.go
@@ -1,6 +1,7 @@
 package models
 
 import (
+	"encoding/json"
 	"fmt"
 	"testing"
 	"time"
@@ -209,3 +210,49 @@ func TestFormatDuration(t *testing.T) {
 	d := FormatDuration(33333333333000000)
 	assert.Equal(t, "1y2w6d19h15m33s333ms", d)
 }
+
+func TestMapDecodingIssue207(t *testing.T) {
+	em := getCborEncoder()
+	dm := getCborDecoder()
+
+	// Test case reproducing issue #207
+	// When decoding maps, they should be decoded as map[string]interface{} for JSON compatibility
+	type DeviceProperties struct {
+		Desired  map[string]any `json:"desired"`
+		Reported map[string]any `json:"reported"`
+	}
+
+	// Create test data with nested maps
+	original := DeviceProperties{
+		Desired: map[string]any{
+			"temperature": 25.5,
+			"humidity":    60,
+			"settings": map[string]any{
+				"mode":  "auto",
+				"level": 3,
+			},
+		},
+		Reported: map[string]any{
+			"temperature": 24.8,
+			"humidity":    58,
+			"status":      "active",
+		},
+	}
+
+	// Although you can obviously round-trip the original struct using cbor...
+
+	encoded, err := em.Marshal(original)
+	assert.NoError(t, err, "Should not error while encoding")
+
+	var decoded DeviceProperties
+	err = dm.Unmarshal(encoded, &decoded)
+	assert.NoError(t, err, "Should not error while decoding")
+
+	// The nested settings map had been decoded as map[inetrface{}]interface{} instead of map[string]interface{}
+	// This is a problem for JSON marshaling, as it expects map[string]interface{}.
+
+	// By doing the following, we ensure that the map[string]interface{} that have nested maps
+	// are properly handled and can be marshaled to JSON without issues.
+	_, err = json.Marshal(decoded)
+	assert.NoError(t, err, "Should be able to marshal decoded struct to JSON")
+}