File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -176,7 +176,12 @@ struct TDSRPCProcRequest {
176176 }
177177
178178 private func writeBVarChar( _ s: String , into buf: inout ByteBuffer ) {
179- let utf16 = Array ( s. utf16)
179+ var name = s
180+ if !name. isEmpty && !name. hasPrefix ( " @ " ) {
181+ name = " @ " + name
182+ }
183+ let utf16 = Array ( name. utf16)
184+ // RPCParamName: 1-byte CHARACTER count prefix
180185 buf. writeInteger ( UInt8 ( utf16. count) )
181186 for unit in utf16 { buf. writeInteger ( unit, endianness: . little) }
182187 }
Original file line number Diff line number Diff line change @@ -25,9 +25,27 @@ public extension SQLValue {
2525 var isNull : Bool { if case . null = self { return true } ; return false }
2626
2727 func asBool( ) -> Bool ? { guard case . bool( let v) = self else { return nil } ; return v }
28- func asInt( ) -> Int ? { guard case . int( let v) = self else { return nil } ; return v }
28+ func asInt( ) -> Int ? {
29+ switch self {
30+ case . int( let v) : return v
31+ case . int8( let v) : return Int ( v)
32+ case . int16( let v) : return Int ( v)
33+ case . int32( let v) : return Int ( v)
34+ case . int64( let v) : return Int ( exactly: v)
35+ default : return nil
36+ }
37+ }
2938 func asInt32( ) -> Int32 ? { guard case . int32( let v) = self else { return nil } ; return v }
30- func asInt64( ) -> Int64 ? { guard case . int64( let v) = self else { return nil } ; return v }
39+ func asInt64( ) -> Int64 ? {
40+ switch self {
41+ case . int64( let v) : return v
42+ case . int32( let v) : return Int64 ( v)
43+ case . int16( let v) : return Int64 ( v)
44+ case . int8( let v) : return Int64 ( v)
45+ case . int( let v) : return Int64 ( v)
46+ default : return nil
47+ }
48+ }
3149 func asFloat( ) -> Float ? { guard case . float( let v) = self else { return nil } ; return v }
3250 func asDouble( ) -> Double ? { guard case . double( let v) = self else { return nil } ; return v }
3351 func asDecimal( ) -> Decimal ? { guard case . decimal( let v) = self else { return nil } ; return v }
You can’t perform that action at this time.
0 commit comments