diff --git a/Gemfile b/Gemfile index d828534..e4a3abd 100644 --- a/Gemfile +++ b/Gemfile @@ -10,3 +10,7 @@ gem "rake" gem "rspec" gem "pry" gem "dotenv" + +group :development do + gem "parallel" +end diff --git a/Gemfile.lock b/Gemfile.lock index 63619f7..afc6246 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ruby_snowflake_client (1.1.0) + ruby_snowflake_client (1.3.0) GEM remote: https://rubygems.org/ @@ -10,6 +10,7 @@ GEM diff-lcs (1.5.0) dotenv (2.8.1) method_source (1.0.0) + parallel (1.23.0) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) @@ -34,6 +35,7 @@ PLATFORMS DEPENDENCIES bundler dotenv + parallel pry rake rspec diff --git a/ext/vendor/github.com/snowflakedb/gosnowflake/errors.go b/ext/vendor/github.com/snowflakedb/gosnowflake/errors.go index c49fc92..3b50503 100644 --- a/ext/vendor/github.com/snowflakedb/gosnowflake/errors.go +++ b/ext/vendor/github.com/snowflakedb/gosnowflake/errors.go @@ -82,7 +82,12 @@ func (se *SnowflakeError) exceptionTelemetry(sc *snowflakeConn) *SnowflakeError // return populated error fields replacing the default response func populateErrorFields(code int, data *execResponse) *SnowflakeError { - err := ErrUnknownError + err := &SnowflakeError{ + Number: -1, + SQLState: "-1", + Message: "an unknown server side error occurred", + QueryID: "-1", + } if code != -1 { err.Number = code } diff --git a/lib/ruby_snowflake_client/version.rb b/lib/ruby_snowflake_client/version.rb index 6d195c0..1af8b18 100644 --- a/lib/ruby_snowflake_client/version.rb +++ b/lib/ruby_snowflake_client/version.rb @@ -1,3 +1,3 @@ module RubySnowflakeClient - VERSION = '1.2.1' + VERSION = '1.3.0' end diff --git a/spec/snowflake/client_spec.rb b/spec/snowflake/client_spec.rb index 8ad3524..8abee58 100644 --- a/spec/snowflake/client_spec.rb +++ b/spec/snowflake/client_spec.rb @@ -62,7 +62,50 @@ sql: query ) end + end + + context "for unauthorized database" do + before do + client.connect( + account: ENV["SNOWFLAKE_ACCOUNT"], + warehouse: ENV["SNOWFLAKE_WAREHOUSE"], + user: ENV["SNOWFLAKE_USER"], + password: ENV["SNOWFLAKE_PASSWORD"], + ) + end + let(:query) { "SELECT * FROM TEST_DATABASE.RINSED_WEB_APP.EMAILS LIMIT 1;" } + it "should raise an exception" do + expect { result }.to raise_error do |error| + expect(error).to be_a Snowflake::Error + expect(error.message).to include "TEST_DATABASE" + expect(error.sentry_context).to include( + sql: query + ) + end + end + it "should raise the correct exception for threaded work" do + require "parallel" + + Parallel.map((1..3).collect { _1 }, in_threads: 2) do |idx| + c = described_class.new + c.connect( + account: ENV["SNOWFLAKE_ACCOUNT"], + warehouse: ENV["SNOWFLAKE_WAREHOUSE"], + user: ENV["SNOWFLAKE_USER"], + password: ENV["SNOWFLAKE_PASSWORD"], + ) + query = "SELECT * FROM TEST_DATABASE#{idx}.RINSED_WEB_APP.EMAILS LIMIT 1;" + + expect { c.fetch(query) }.to raise_error do |error| + expect(error).to be_a Snowflake::Error + expect(error.sentry_context).to include( + sql: query + ) + expect(error.message).to include "TEST_DATABASE#{idx}" + end + end + end end end