Skip to content

Commit a7bf54b

Browse files
authored
Add support for SurrealDB v3 structured error handling (#382)
1 parent 89d0f8d commit a7bf54b

File tree

16 files changed

+821
-16
lines changed

16 files changed

+821
-16
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
include:
19-
# v3.0.0-beta.2 with Go 1.25.0
20-
- surrealdb-version: 'v3.0.0-beta.2'
19+
# v3.0.1 with Go 1.25.0
20+
- surrealdb-version: 'v3.0.1'
2121
go-version: '1.25.0'
2222
connection-type: 'ws'
2323
surrealdb-url: 'ws://localhost:8000/rpc'
24-
- surrealdb-version: 'v3.0.0-beta.2'
24+
- surrealdb-version: 'v3.0.1'
2525
go-version: '1.25.0'
2626
connection-type: 'http'
2727
surrealdb-url: 'http://localhost:8000'

.golangci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ linters:
3333
goconst:
3434
min-len: 2
3535
min-occurrences: 3
36+
gosec:
37+
excludes:
38+
# Password fields are fundamental to a DB SDK
39+
- G117
40+
# HTTP requests use URLs from user configuration, not tainted input
41+
- G704
42+
# Log messages contain DB metadata (namespace/table names), not user input
43+
- G706
3644
gocritic:
3745
disabled-checks:
3846
- dupImport

contrib/surrealql/define.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (q *DefineTableQuery) Build() (query string, params map[string]any) {
107107
if len(q.permissions) > 0 {
108108
builder.WriteString(" PERMISSIONS")
109109
for _, p := range q.permissions {
110-
builder.WriteString(fmt.Sprintf(" %s %s", strings.ToUpper(p.perm), p.value))
110+
fmt.Fprintf(&builder, " %s %s", strings.ToUpper(p.perm), p.value)
111111
}
112112
}
113113

contrib/surrealql/show.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (q *ShowChangesForTableQuery) Build() (sql string, vars map[string]any) {
8080
}
8181

8282
if q.limit > 0 {
83-
builder.WriteString(fmt.Sprintf(" LIMIT %d", q.limit))
83+
fmt.Fprintf(&builder, " LIMIT %d", q.limit)
8484
}
8585

8686
return builder.String(), c.vars

contrib/surrealrestore/restore_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ func TestRestorerFull(t *testing.T) {
3939
t.Fatalf("Failed to init source db: %v", err)
4040
}
4141

42+
// Check if this is SurrealDB 3.x - skip due to changefeed behavior changes
43+
// This may be revisited once 3.0 GA is out and changefeed behavior is stable
44+
v, vErr := testenv.GetVersion(ctx, sourceDB)
45+
if vErr != nil {
46+
t.Fatalf("Failed to get SurrealDB version: %v", vErr)
47+
}
48+
if v.IsV3OrLater() {
49+
t.Skip("Skipping incremental dump/restore test on SurrealDB 3.x - changefeed behavior has changed significantly")
50+
}
51+
4252
// Insert test data
4353
type TestRecord struct {
4454
ID string `json:"id,omitempty"`

0 commit comments

Comments
 (0)