github-ds 0.2.2 → 0.2.3

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
  SHA1:
3
- metadata.gz: 71f03b79bb5da02405c55e147147550eede9a120
4
- data.tar.gz: 69c8978ef97b5d7a45e005cbbdf371ce601c68bc
3
+ metadata.gz: 4f0dadce425b6c2825dfc31cb30dded17ca6c3e3
4
+ data.tar.gz: c97fde1c4929410829d1c0c5f91a9a9395f04cf5
5
5
  SHA512:
6
- metadata.gz: 4d7c7c75907e73190497e58bdda8a9729a334e7aa05f6482c57ea1f0a48ed0db9871728604f7160e23d02e0d641d581241113d3f0bb85b90959c877b2fa84b44
7
- data.tar.gz: 600871b7b135f7d0544e74e05921e97b1e6c292046b14306bbbe68155c3c8df7bb3a42a2abe18769db41c011787c82dfd1cd3d3411b3fd10ab8b55f92b413971
6
+ metadata.gz: 66eb4455a6fcc0cfe31a643e333d07681df935e1f841d69206637c1eb7c444c048e62f69ea7a7697af4895f879c4a027edfab8be0afb77f7f2155a88d17e0da6
7
+ data.tar.gz: 491aef5523514c7d95ebcf69523a9ae1f88e38abbb524ed0ac5648545e22323bf5c2142c4e223671f89cbb1f3daca219890268a15c9049ec64ad6f708dacab6b
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.3
4
+
5
+ Additions
6
+
7
+ * github-ds does not use `blank?` anymore hence not depending on `active_support/core_ext/object/blank` https://github.com/github/github-ds/commit/a22c397eaaa00bb441fb4a0ecdf3e371daa9001a
8
+
9
+ Fixes
10
+
11
+ * `ActiveRecord::Base.default_timezone` is not unintentionally set to `nil` https://github.com/github/github-ds/pull/22
12
+
3
13
  ## 0.2.2
4
14
 
5
15
  Additions
data/README.md CHANGED
@@ -208,6 +208,7 @@ Nothing currently on our radar other than continued maintenance. Have a big idea
208
208
  |---|---|
209
209
  | ![@charliesome](https://avatars3.githubusercontent.com/u/179065?s=64) | [@charliesome](https://github.com/charliesome) |
210
210
  | ![@jnunemaker](https://avatars3.githubusercontent.com/u/235?s=64) | [@jnunemaker](https://github.com/jnunemaker) |
211
+ | ![@miguelff](https://avatars3.githubusercontent.com/u/210307?s=64) | [@miguelff](https://github.com/miguelff) |
211
212
  | ![@zerowidth](https://avatars3.githubusercontent.com/u/3999?s=64) | [@zerowidth](https://github.com/zerowidth) |
212
213
 
213
214
  ## License
@@ -1,5 +1,5 @@
1
1
  module GitHub
2
2
  module DS
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
@@ -149,7 +149,7 @@ module GitHub
149
149
  @connection = @binds.delete :connection
150
150
  @force_tz = @binds.delete :force_timezone
151
151
 
152
- add query if !query.nil?
152
+ add query
153
153
  end
154
154
 
155
155
  # Public: Add a chunk of SQL to the query. Any ":keyword" tokens in the SQL
@@ -163,20 +163,22 @@ module GitHub
163
163
  # Returns self.
164
164
  # Raises GitHub::SQL::BadBind for unknown keyword tokens.
165
165
  def add(sql, extras = nil)
166
- return self if sql.blank?
166
+ return self if sql.nil? || sql.empty?
167
167
 
168
168
  query << " " unless query.empty?
169
169
 
170
- if @force_tz
171
- zone = ActiveRecord::Base.default_timezone
172
- ActiveRecord::Base.default_timezone = @force_tz
173
- end
170
+ begin
171
+ if @force_tz
172
+ zone = ActiveRecord::Base.default_timezone
173
+ ActiveRecord::Base.default_timezone = @force_tz
174
+ end
174
175
 
175
- query << interpolate(sql.strip, extras)
176
+ query << interpolate(sql.strip, extras)
176
177
 
177
- self
178
- ensure
179
- ActiveRecord::Base.default_timezone = zone if @force_tz
178
+ self
179
+ ensure
180
+ ActiveRecord::Base.default_timezone = zone if @force_tz
181
+ end
180
182
  end
181
183
 
182
184
  # Public: Add a chunk of SQL to the query, unless query generated so far is empty.
@@ -270,38 +272,40 @@ module GitHub
270
272
  return @results if defined? @results
271
273
  return [] if frozen?
272
274
 
273
- if @force_tz
274
- zone = ActiveRecord::Base.default_timezone
275
- ActiveRecord::Base.default_timezone = @force_tz
276
- end
275
+ begin
276
+ if @force_tz
277
+ zone = ActiveRecord::Base.default_timezone
278
+ ActiveRecord::Base.default_timezone = @force_tz
279
+ end
277
280
 
278
- case query
279
- when /\ADELETE/i
280
- @affected_rows = connection.delete(query, "#{self.class.name} Delete")
281
+ case query
282
+ when /\ADELETE/i
283
+ @affected_rows = connection.delete(query, "#{self.class.name} Delete")
281
284
 
282
- when /\AINSERT/i
283
- @last_insert_id = connection.insert(query, "#{self.class.name} Insert")
285
+ when /\AINSERT/i
286
+ @last_insert_id = connection.insert(query, "#{self.class.name} Insert")
284
287
 
285
- when /\AUPDATE/i
286
- @affected_rows = connection.update(query, "#{self.class.name} Update")
288
+ when /\AUPDATE/i
289
+ @affected_rows = connection.update(query, "#{self.class.name} Update")
287
290
 
288
- when /\ASELECT/i
289
- # Why not execute or select_rows? Because select_all hits the query cache.
290
- @hash_results = connection.select_all(query, "#{self.class.name} Select")
291
- @results = @hash_results.map(&:values)
291
+ when /\ASELECT/i
292
+ # Why not execute or select_rows? Because select_all hits the query cache.
293
+ @hash_results = connection.select_all(query, "#{self.class.name} Select")
294
+ @results = @hash_results.map(&:values)
292
295
 
293
- else
294
- @results = connection.execute(query, "#{self.class.name} Execute").to_a
295
- end
296
+ else
297
+ @results = connection.execute(query, "#{self.class.name} Execute").to_a
298
+ end
296
299
 
297
- @results ||= []
300
+ @results ||= []
298
301
 
299
- retrieve_found_row_count
300
- freeze
302
+ retrieve_found_row_count
303
+ freeze
301
304
 
302
- @results
303
- ensure
304
- ActiveRecord::Base.default_timezone = zone if @force_tz
305
+ @results
306
+ ensure
307
+ ActiveRecord::Base.default_timezone = zone if @force_tz
308
+ end
305
309
  end
306
310
 
307
311
  # Public: If the query is a SELECT, return an array of hashes instead of an array of arrays.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-ds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-09-14 00:00:00.000000000 Z
12
+ date: 2017-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  version: '0'
189
189
  requirements: []
190
190
  rubyforge_project:
191
- rubygems_version: 2.5.2
191
+ rubygems_version: 2.4.5.1
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: A collection of libraries for working with SQL on top of ActiveRecord's connection.