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 +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +1 -0
- data/lib/github/ds/version.rb +1 -1
- data/lib/github/sql.rb +38 -34
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f0dadce425b6c2825dfc31cb30dded17ca6c3e3
|
4
|
+
data.tar.gz: c97fde1c4929410829d1c0c5f91a9a9395f04cf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66eb4455a6fcc0cfe31a643e333d07681df935e1f841d69206637c1eb7c444c048e62f69ea7a7697af4895f879c4a027edfab8be0afb77f7f2155a88d17e0da6
|
7
|
+
data.tar.gz: 491aef5523514c7d95ebcf69523a9ae1f88e38abbb524ed0ac5648545e22323bf5c2142c4e223671f89cbb1f3daca219890268a15c9049ec64ad6f708dacab6b
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/lib/github/ds/version.rb
CHANGED
data/lib/github/sql.rb
CHANGED
@@ -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
|
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.
|
166
|
+
return self if sql.nil? || sql.empty?
|
167
167
|
|
168
168
|
query << " " unless query.empty?
|
169
169
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
170
|
+
begin
|
171
|
+
if @force_tz
|
172
|
+
zone = ActiveRecord::Base.default_timezone
|
173
|
+
ActiveRecord::Base.default_timezone = @force_tz
|
174
|
+
end
|
174
175
|
|
175
|
-
|
176
|
+
query << interpolate(sql.strip, extras)
|
176
177
|
|
177
|
-
|
178
|
-
|
179
|
-
|
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
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
275
|
+
begin
|
276
|
+
if @force_tz
|
277
|
+
zone = ActiveRecord::Base.default_timezone
|
278
|
+
ActiveRecord::Base.default_timezone = @force_tz
|
279
|
+
end
|
277
280
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
+
case query
|
282
|
+
when /\ADELETE/i
|
283
|
+
@affected_rows = connection.delete(query, "#{self.class.name} Delete")
|
281
284
|
|
282
|
-
|
283
|
-
|
285
|
+
when /\AINSERT/i
|
286
|
+
@last_insert_id = connection.insert(query, "#{self.class.name} Insert")
|
284
287
|
|
285
|
-
|
286
|
-
|
288
|
+
when /\AUPDATE/i
|
289
|
+
@affected_rows = connection.update(query, "#{self.class.name} Update")
|
287
290
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
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
|
-
|
294
|
-
|
295
|
-
|
296
|
+
else
|
297
|
+
@results = connection.execute(query, "#{self.class.name} Execute").to_a
|
298
|
+
end
|
296
299
|
|
297
|
-
|
300
|
+
@results ||= []
|
298
301
|
|
299
|
-
|
300
|
-
|
302
|
+
retrieve_found_row_count
|
303
|
+
freeze
|
301
304
|
|
302
|
-
|
303
|
-
|
304
|
-
|
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.
|
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-
|
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.
|
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.
|