Skip to content

Commit 0bbe7fd

Browse files
committed
Fixed some type aliases not being correctly encoded when using 'Expr'. Fixes #248
1 parent 435e7f3 commit 0bbe7fd

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2121
- Deprecated the option `NodeRefreshInterval` in `ConnectOpts`
2222
- Deprecated `SetMaxIdleConns` and `SetMaxOpenConns`, these options should now only be set when creating the session.
2323

24+
### Fixed
25+
- Fixed some type aliases not being correctly encoded when using `Expr`.
26+
2427
## v1.1.4
2528
### Added
2629
- Added root table terms (`r.TableCreate`, `r.TableList` and `r.TableDrop`)

query_control.go

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,41 @@ func Expr(val interface{}) Term {
5959
}
6060

6161
return makeObject(vals)
62+
case
63+
bool,
64+
int,
65+
int8,
66+
int16,
67+
int32,
68+
int64,
69+
uint,
70+
uint8,
71+
uint16,
72+
uint32,
73+
uint64,
74+
float32,
75+
float64,
76+
uintptr,
77+
string,
78+
*bool,
79+
*int,
80+
*int8,
81+
*int16,
82+
*int32,
83+
*int64,
84+
*uint,
85+
*uint8,
86+
*uint16,
87+
*uint32,
88+
*uint64,
89+
*float32,
90+
*float64,
91+
*uintptr,
92+
*string:
93+
return Term{
94+
termType: p.Term_DATUM,
95+
data: val,
96+
}
6297
default:
6398
// Use reflection to check for other types
6499
valType := reflect.TypeOf(val)
@@ -103,9 +138,19 @@ func Expr(val interface{}) Term {
103138

104139
return makeArray(vals)
105140
default:
141+
data, err := encode(val)
142+
143+
if err != nil || data == nil {
144+
return Term{
145+
termType: p.Term_DATUM,
146+
data: nil,
147+
lastErr: err,
148+
}
149+
}
150+
106151
return Term{
107152
termType: p.Term_DATUM,
108-
data: val,
153+
data: data,
109154
}
110155
}
111156
}

0 commit comments

Comments
 (0)