ruby_snowflake_client 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/ext/result.go +12 -3
- data/ext/ruby_snowflake.go +1 -1
- data/lib/ruby_snowflake_client/version.rb +1 -1
- data/lib/ruby_snowflake_client.rb +20 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e0c56fd4b0b95f40bbd1ed55dc9fb10bc6284ac198b527b3dfa977f2419fa5f
|
4
|
+
data.tar.gz: 9351e25573c2553ec2ab6123df8d829e53749ee25e5c6a82de9d4c1e7ca65c4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d414d31259999434fc6323be3fb41a3d1fa854fccad0a09902885bab19e5ed5c68e921d1ca254baaf2cf11f46e91b1fcb9c66f6656f0130798774e5b95f44f48
|
7
|
+
data.tar.gz: a4e515cdf374ca890ba03ca04602c10f0382bf4768d626d03d50a9febf26f8930bc294a56e8447290bd4677163521c35f9fded4dd81d7741f0d1bb087507c751
|
data/Gemfile.lock
CHANGED
data/ext/result.go
CHANGED
@@ -21,6 +21,12 @@ import (
|
|
21
21
|
gopointer "github.com/mattn/go-pointer"
|
22
22
|
)
|
23
23
|
|
24
|
+
func wrapRbRaise(err error) {
|
25
|
+
fmt.Printf("[ruby-snowflake-client] Error encountered: %s\n", err.Error())
|
26
|
+
fmt.Printf("[ruby-snowflake-client] Will call `rb_raise`\n")
|
27
|
+
rb_raise(C.rb_eArgError, "%s", err.Error())
|
28
|
+
}
|
29
|
+
|
24
30
|
func getResultStruct(self C.VALUE) *SnowflakeResult {
|
25
31
|
ivar := C.rb_ivar_get(self, RESULT_IDENTIFIER)
|
26
32
|
|
@@ -28,7 +34,8 @@ func getResultStruct(self C.VALUE) *SnowflakeResult {
|
|
28
34
|
ptr := gopointer.Restore(str)
|
29
35
|
sr, ok := ptr.(*SnowflakeResult)
|
30
36
|
if !ok || sr.rows == nil {
|
31
|
-
|
37
|
+
err := errors.New("Empty result; please run a query via `client.fetch(\"SQL\")`")
|
38
|
+
wrapRbRaise(err)
|
32
39
|
return nil
|
33
40
|
}
|
34
41
|
|
@@ -105,7 +112,8 @@ func (res SnowflakeResult) ScanNextRow(debug bool) C.VALUE {
|
|
105
112
|
|
106
113
|
err := rows.Scan(rawData...)
|
107
114
|
if err != nil {
|
108
|
-
|
115
|
+
err = fmt.Errorf("Cannot scan row: '%s'", err)
|
116
|
+
wrapRbRaise(err)
|
109
117
|
}
|
110
118
|
|
111
119
|
// trick from postgres; keep hash: pg_result.c:1088
|
@@ -139,7 +147,8 @@ func (res SnowflakeResult) ScanNextRow(debug bool) C.VALUE {
|
|
139
147
|
str := v
|
140
148
|
rbVal = RbString(str)
|
141
149
|
default:
|
142
|
-
|
150
|
+
err := fmt.Errorf("Cannot parse type : '%T'", v)
|
151
|
+
wrapRbRaise(err)
|
143
152
|
}
|
144
153
|
}
|
145
154
|
C.rb_hash_aset(hash, col_name, rbVal)
|
data/ext/ruby_snowflake.go
CHANGED
@@ -136,7 +136,7 @@ func ObjFetch(self C.VALUE, statement C.VALUE) C.VALUE {
|
|
136
136
|
f := gopointer.Restore(req)
|
137
137
|
x, ok := f.(*SnowflakeClient)
|
138
138
|
if !ok {
|
139
|
-
|
139
|
+
wrapRbRaise((errors.New("cannot convert SnowflakeClient pointer in ObjFetch")))
|
140
140
|
}
|
141
141
|
|
142
142
|
return x.Fetch(statement)
|
@@ -3,15 +3,32 @@
|
|
3
3
|
module Snowflake
|
4
4
|
require "ruby_snowflake_client_ext" # build bundle of the go files
|
5
5
|
|
6
|
+
class Error < StandardError
|
7
|
+
attr_reader :details
|
8
|
+
|
9
|
+
def initialize(details)
|
10
|
+
@details = details
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
6
14
|
class Client
|
7
15
|
attr_reader :error
|
8
16
|
# Wrap the private _connect method, as sending kwargs to Go would require
|
9
17
|
# wrapping the function in C as the current CGO has a limitation on
|
10
18
|
# accepting variadic arguments for functions.
|
11
19
|
def connect(account:"", warehouse:"", database:"", schema: "", user: "", password: "", role: "")
|
12
|
-
|
20
|
+
@connection_details = {
|
21
|
+
account: account,
|
22
|
+
warehouse: warehouse,
|
23
|
+
database: database,
|
24
|
+
schema: schema,
|
25
|
+
user: user,
|
26
|
+
role: role
|
27
|
+
}
|
28
|
+
|
29
|
+
_connect(account.dup, warehouse.dup, database.dup, schema.dup, user.dup, password.dup, role.dup)
|
13
30
|
if error != nil
|
14
|
-
raise(error
|
31
|
+
raise Error.new(@connection_details), error
|
15
32
|
end
|
16
33
|
true
|
17
34
|
end
|
@@ -19,7 +36,7 @@ module Snowflake
|
|
19
36
|
def fetch(sql)
|
20
37
|
result = _fetch(sql)
|
21
38
|
return result if result.valid?
|
22
|
-
raise(result.error
|
39
|
+
raise Error.new(@connection_details.merge(sql: sql)), result.error
|
23
40
|
end
|
24
41
|
end
|
25
42
|
|