blazer 2.6.1 → 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: 9730ca392e0f5bf0d7ff9b186ee554914c12f204c9250ae0f4e8101334a8eb0a
4
- data.tar.gz: a82b46348506e422ba96db6ad70755a6f18a70f65d3b44d9bab53c598af9393b
3
+ metadata.gz: b32d2190afc8df872db60250651c97eae9d202d0b23042a4b853169edbc2d458
4
+ data.tar.gz: 64cb17476627ce2108e2aaf9619648e4a743774983c29bcb7478a3b4500f4617
5
5
  SHA512:
6
- metadata.gz: d1dfa10786ea69f0d3603549c572132643162b994bdc78ee8ed06a3b0dfae4e5cb748f02ae2433ccac4962dcf94c67f20a57baec400ed2da6ea9a5bf882a49db
7
- data.tar.gz: 4c98700f9adac11025fb337d91e992c3f347b8a61b499938d15505b3e40216029f0edb3faa2c6fa85810375f3d41ba65f2abb8c5e33f0c819cedc95aab0a8c7e
6
+ metadata.gz: d6eb64793a84ba433e6a68caaa5419dbcbb3f80ae842854b486f552459e77b434bc7d43bacf1d97175fea1857c74e66b440f7de55cc1e591133740f47ea84f18
7
+ data.tar.gz: 0723a52bb56f41d3526d66799f19a6fa82b91cd51aa3a35b5bede9523012bc0cee291db1f6e71eb74657c8e595ac0dc1b3f20febb1687121c35830456b924c2a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
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
+
1
13
  ## 2.6.1 (2022-04-21)
2
14
 
3
15
  - Added `region` setting to Amazon Athena
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.
@@ -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 %>
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Blazer
2
- VERSION = "2.6.1"
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.1
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-21 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