blazer 2.6.0 → 2.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bdfc1e428f7e01bf9a06461a5f0143a6e940cd1e3d708ba2bd504132bbaa1db
4
- data.tar.gz: 729e9a408e7f4fa5203ab4c133800e49087fccf634efcf7c9dd6ca80a610a861
3
+ metadata.gz: b32d2190afc8df872db60250651c97eae9d202d0b23042a4b853169edbc2d458
4
+ data.tar.gz: 64cb17476627ce2108e2aaf9619648e4a743774983c29bcb7478a3b4500f4617
5
5
  SHA512:
6
- metadata.gz: e6c7a7be80246c1030170a5df95656947b2431cf908bb6d37d668cbe3f57006ef096d63186976c63c683f0e2511873cabb5d2be56e389de331487666ba297dc3
7
- data.tar.gz: 9feb70216244f77d37357376cd68b9ec85a6d3eeb3c89f3e58196688e81618ca2ae38372e5491e0811bdd7d9e0082317a711040f5782cc54f5d9f99ec57d624a
6
+ metadata.gz: d6eb64793a84ba433e6a68caaa5419dbcbb3f80ae842854b486f552459e77b434bc7d43bacf1d97175fea1857c74e66b440f7de55cc1e591133740f47ea84f18
7
+ data.tar.gz: 0723a52bb56f41d3526d66799f19a6fa82b91cd51aa3a35b5bede9523012bc0cee291db1f6e71eb74657c8e595ac0dc1b3f20febb1687121c35830456b924c2a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 2.6.4 (2022-05-24)
2
+
3
+ - Fixed error with caching
4
+
5
+ ## 2.6.3 (2022-05-11)
6
+
7
+ - Fixed error with canceling queries
8
+
9
+ ## 2.6.2 (2022-05-06)
10
+
11
+ - Fixed error with Postgres when prepared statements are disabled with Rails < 6.1
12
+
13
+ ## 2.6.1 (2022-04-21)
14
+
15
+ - Added `region` setting to Amazon Athena
16
+ - Fixed error with MySQL for Rails < 7
17
+ - Fixed error with binary data
18
+
1
19
  ## 2.6.0 (2022-04-20)
2
20
 
3
21
  - Fixed quoting issue with variables
data/README.md CHANGED
@@ -150,8 +150,8 @@ Create a user with read-only permissions:
150
150
 
151
151
  ```sql
152
152
  BEGIN;
153
- CREATE ROLE blazer LOGIN PASSWORD 'secret123';
154
- GRANT CONNECT ON DATABASE database_name TO blazer;
153
+ CREATE ROLE blazer LOGIN PASSWORD 'secret';
154
+ GRANT CONNECT ON DATABASE dbname TO blazer;
155
155
  GRANT USAGE ON SCHEMA public TO blazer;
156
156
  GRANT SELECT ON ALL TABLES IN SCHEMA public TO blazer;
157
157
  ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO blazer;
@@ -163,7 +163,8 @@ COMMIT;
163
163
  Create a user with read-only permissions:
164
164
 
165
165
  ```sql
166
- GRANT SELECT, SHOW VIEW ON database_name.* TO blazer@’127.0.0.1 IDENTIFIED BY ‘secret123‘;
166
+ CREATE USER 'blazer'@'127.0.0.1' IDENTIFIED BY 'secret';
167
+ GRANT SELECT, SHOW VIEW ON dbname.* TO 'blazer'@'127.0.0.1';
167
168
  FLUSH PRIVILEGES;
168
169
  ```
169
170
 
@@ -171,8 +172,8 @@ FLUSH PRIVILEGES;
171
172
 
172
173
  Create a user with read-only permissions:
173
174
 
174
- ```
175
- db.createUser({user: "blazer", pwd: "password", roles: ["read"]})
175
+ ```javascript
176
+ db.createUser({user: "blazer", pwd: "secret", roles: ["read"]})
176
177
  ```
177
178
 
178
179
  Also, make sure authorization is enabled when you start the server.
@@ -607,6 +608,7 @@ data_sources:
607
608
  workgroup: primary
608
609
  access_key_id: ...
609
610
  secret_access_key: ...
611
+ region: ...
610
612
  ```
611
613
 
612
614
  Here’s an example IAM policy:
@@ -709,7 +711,7 @@ Use a read-only user. Requires the [Thrift server](https://spark.apache.org/docs
709
711
 
710
712
  ### Cassandra
711
713
 
712
- Add [cassandra-driver](https://github.com/datastax/ruby-driver) to your Gemfile and set:
714
+ Add [cassandra-driver](https://github.com/datastax/ruby-driver) (and [sorted_set](https://github.com/knu/sorted_set) for Ruby 3+) to your Gemfile and set:
713
715
 
714
716
  ```yml
715
717
  data_sources:
@@ -3,6 +3,9 @@ var runningQueries = []
3
3
  var maxQueries = 3
4
4
 
5
5
  function runQuery(data, success, error) {
6
+ if (!data.data_source) {
7
+ throw new Error("Data source is required to cancel queries")
8
+ }
6
9
  data.run_id = uuid()
7
10
  var query = {
8
11
  data: data,
@@ -50,7 +53,11 @@ function runQueryHelper(query) {
50
53
  queryComplete(query)
51
54
  }
52
55
  }).fail( function(jqXHR, textStatus, errorThrown) {
53
- if (!query.canceled) {
56
+ // check jqXHR.status instead of query.canceled
57
+ // so it works for page navigation with Firefox and Safari
58
+ if (jqXHR.status === 0) {
59
+ cancelServerQuery(query)
60
+ } else {
54
61
  var message = (typeof errorThrown === "string") ? errorThrown : errorThrown.message
55
62
  if (!message) {
56
63
  message = "An error occurred"
@@ -83,6 +90,8 @@ function cancelAllQueries() {
83
90
  }
84
91
  }
85
92
 
93
+ // needed for Chrome
94
+ // queries are canceled before unload with Firefox and Safari
86
95
  $(window).on("unload", cancelAllQueries)
87
96
 
88
97
  function cancelQuery(query) {
@@ -90,7 +99,9 @@ function cancelQuery(query) {
90
99
  if (query.xhr) {
91
100
  query.xhr.abort()
92
101
  }
102
+ }
93
103
 
104
+ function cancelServerQuery(query) {
94
105
  // tell server
95
106
  var path = Routes.cancel_queries_path()
96
107
  var data = {run_id: query.run_id, data_source: query.data_source}
@@ -92,6 +92,7 @@ module Blazer
92
92
  @cohort_analysis = @statement.cohort_analysis?
93
93
 
94
94
  # fallback for now for users with open tabs
95
+ # TODO remove fallback in future version
95
96
  @var_params = request.request_parameters["variables"] || request.request_parameters
96
97
  @success = process_vars(@statement, @var_params)
97
98
  @only_chart = params[:only_chart]
@@ -39,7 +39,9 @@
39
39
  </div>
40
40
  </div>
41
41
  <script>
42
- <%= blazer_js_var "data", {statement: query.statement, query_id: query.id, variables: variable_params(query), only_chart: true, cohort_period: params[:cohort_period]} %>
42
+ <% data = {statement: query.statement, query_id: query.id, data_source: query.data_source, variables: variable_params(query), only_chart: true} %>
43
+ <% data.merge!(cohort_period: params[:cohort_period]) if params[:cohort_period] %>
44
+ <%= blazer_js_var "data", data %>
43
45
 
44
46
  runQuery(data, function (data) {
45
47
  $("#chart-<%= i %>").html(data)
@@ -1,7 +1,7 @@
1
1
  <% blazer_title @query.name %>
2
2
 
3
3
  <% if @success %>
4
- <% run_data = {statement: @query.statement, query_id: @query.id, variables: variable_params(@query)} %>
4
+ <% run_data = {statement: @query.statement, query_id: @query.id, data_source: @query.data_source, variables: variable_params(@query)} %>
5
5
  <% run_data.merge!(forecast: "t") if params[:forecast] %>
6
6
  <% run_data.merge!(cohort_period: params[:cohort_period]) if params[:cohort_period] %>
7
7
  <% run_data.transform_keys!(&:to_s) if Rails::VERSION::STRING.to_f == 5.0 %>
@@ -169,11 +169,12 @@ module Blazer
169
169
 
170
170
  def client_options
171
171
  @client_options ||= begin
172
+ options = {}
172
173
  if settings["access_key_id"] || settings["secret_access_key"]
173
- {credentials: Aws::Credentials.new(settings["access_key_id"], settings["secret_access_key"])}
174
- else
175
- {}
174
+ options[:credentials] = Aws::Credentials.new(settings["access_key_id"], settings["secret_access_key"])
176
175
  end
176
+ options[:region] = settings["region"] if settings["region"]
177
+ options
177
178
  end
178
179
  end
179
180
  end
@@ -191,9 +191,12 @@ module Blazer
191
191
 
192
192
  # Redshift adapter silently ignores binds
193
193
  def parameter_binding
194
- if postgresql? || sqlite?
194
+ if postgresql? && (ActiveRecord::VERSION::STRING.to_f >= 6.1 || prepared_statements?)
195
+ # Active Record < 6.1 silently ignores binds with Postgres when prepared statements are disabled
195
196
  :numeric
196
- elsif mysql? && connection_model.connection.prepared_statements?
197
+ elsif sqlite?
198
+ :numeric
199
+ elsif mysql? && prepared_statements?
197
200
  # Active Record silently ignores binds with MySQL when prepared statements are disabled
198
201
  :positional
199
202
  elsif sqlserver?
@@ -309,6 +312,10 @@ module Blazer
309
312
  end
310
313
  end
311
314
  end
315
+
316
+ def prepared_statements?
317
+ connection_model.connection.prepared_statements
318
+ end
312
319
  end
313
320
  end
314
321
  end
@@ -145,7 +145,7 @@ module Blazer
145
145
  end
146
146
 
147
147
  def statement_cache_key(statement)
148
- cache_key(["statement", id, Digest::MD5.hexdigest(statement.bind_statement.to_s.gsub("\r\n", "\n") + statement.bind_values.sort_by { |k, _| k }.to_json)])
148
+ cache_key(["statement", id, Digest::MD5.hexdigest(statement.bind_statement.to_s.gsub("\r\n", "\n") + statement.bind_values.to_json)])
149
149
  end
150
150
 
151
151
  def run_cache_key(run_id)
data/lib/blazer/result.rb CHANGED
@@ -56,6 +56,8 @@ module Blazer
56
56
  "time"
57
57
  elsif v.nil?
58
58
  nil
59
+ elsif v.is_a?(String) && v.encoding == Encoding::BINARY
60
+ "binary"
59
61
  else
60
62
  "string"
61
63
  end
@@ -1,3 +1,3 @@
1
1
  module Blazer
2
- VERSION = "2.6.0"
2
+ VERSION = "2.6.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-20 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties