github-ds 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +7 -7
- data/CHANGELOG.md +6 -0
- data/Gemfile +6 -0
- data/README.md +2 -0
- data/docker-compose.yml +8 -0
- data/lib/github/ds/version.rb +1 -1
- data/lib/github/kv.rb +23 -0
- data/lib/github/sql.rb +13 -6
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 716ec52fb178302c762091225dc4ab8b1b61a793
|
4
|
+
data.tar.gz: dd79687dfd3a302ebff1978a9f2ea18adf649a05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f23f9d2e7467159b263ec39352c22f1e400198a81dc5294fea08c0e99361f9fe76a44f5a694979fe72359cf8d174dd9655503e8c7f8ea3aa3a0bc8cbb4c28468
|
7
|
+
data.tar.gz: 732716e7a5a28b5526934ad854e1148b17c35322546d01fce321b26417067dd9542d026ef69dfed371dede8a744871a3a505053fc93a7c560de851a845e663e5
|
data/.travis.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.2
|
4
|
-
- 2.3
|
5
|
-
- 2.4
|
6
|
-
|
3
|
+
- 2.2
|
4
|
+
- 2.3
|
5
|
+
- 2.4
|
6
|
+
- 2.5
|
7
7
|
script: bundle exec rake
|
8
8
|
env:
|
9
|
-
- RAILS_VERSION=5.1.
|
10
|
-
- RAILS_VERSION=5.0.
|
11
|
-
- RAILS_VERSION=4.2.
|
9
|
+
- RAILS_VERSION=5.1.5
|
10
|
+
- RAILS_VERSION=5.0.6
|
11
|
+
- RAILS_VERSION=4.2.10
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.2.9
|
4
|
+
|
5
|
+
Fixes
|
6
|
+
|
7
|
+
* Passing duplicate values to columns in a SQL statement (ex `SELECT id, NULL, NULL, name from repositories`) used to return an array of results with de-duplicated values. (ex `[[1, nil, "github"]]` instead of `[[1, nil, nil, "github"]]`. This had some unfortunate side-effects when parsing results so we changed the code to behave closer to `ActiveRecord::Result` objects. Now if you pass duplicated columns the `results` array will return all the values. The hash will only return unique columns because hashes cannot contain duplicate keys.
|
8
|
+
|
3
9
|
## 0.2.8
|
4
10
|
|
5
11
|
Fixes
|
data/Gemfile
CHANGED
@@ -2,5 +2,11 @@ source "https://rubygems.org"
|
|
2
2
|
gemspec
|
3
3
|
|
4
4
|
DEFAULT_RAILS_VERSION = '5.0.2'
|
5
|
+
|
6
|
+
if ENV['RAILS_VERSION'] = '4.2.10'
|
7
|
+
gem 'mysql2', '~> 0.3.18'
|
8
|
+
else
|
9
|
+
gem "mysql2"
|
10
|
+
end
|
5
11
|
gem "rails", "~> #{ENV['RAILS_VERSION'] || DEFAULT_RAILS_VERSION}"
|
6
12
|
gem "activerecord", "~> #{ENV['RAILS_VERSION'] || DEFAULT_RAILS_VERSION}"
|
data/README.md
CHANGED
@@ -191,6 +191,8 @@ KV supports expiring keys and obeys expiration when performing operations, but d
|
|
191
191
|
|
192
192
|
After checking out the repo, run `script/bootstrap` to install dependencies. Then, run `script/test` to run the tests. You can also run `script/console` for an interactive prompt that will allow you to experiment.
|
193
193
|
|
194
|
+
**Note**: You will need a MySQL database with no password set for the root user for the tests. Running `docker-compose up` will boot just that. This functionality is not currently used by GitHub and was from a contributor, so please let us know if it does not work or gets out of date (pull request is best, but an issue will do).
|
195
|
+
|
194
196
|
To install this gem onto your local machine, run `script/install`. To release a new version, update the version number in `version.rb`, commit, and then run `script/release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
195
197
|
|
196
198
|
## Contributing
|
data/docker-compose.yml
ADDED
data/lib/github/ds/version.rb
CHANGED
data/lib/github/kv.rb
CHANGED
@@ -270,6 +270,29 @@ module GitHub
|
|
270
270
|
nil
|
271
271
|
end
|
272
272
|
|
273
|
+
# ttl :: String -> Result<[Time | nil]>
|
274
|
+
#
|
275
|
+
# Returns the expires_at time for the specified key or nil.
|
276
|
+
#
|
277
|
+
# Example:
|
278
|
+
#
|
279
|
+
# kv.ttl("foo")
|
280
|
+
# # => #<Result value: 2018-04-23 11:34:54 +0200>
|
281
|
+
#
|
282
|
+
# kv.ttl("foo")
|
283
|
+
# # => #<Result value: nil>
|
284
|
+
#
|
285
|
+
def ttl(key)
|
286
|
+
validate_key(key)
|
287
|
+
|
288
|
+
Result.new {
|
289
|
+
GitHub::SQL.value(<<-SQL, :key => key, :connection => connection)
|
290
|
+
SELECT expires_at FROM key_values
|
291
|
+
WHERE `key` = :key AND (expires_at IS NULL OR expires_at > NOW())
|
292
|
+
SQL
|
293
|
+
}
|
294
|
+
end
|
295
|
+
|
273
296
|
private
|
274
297
|
def validate_key(key, error_message: nil)
|
275
298
|
unless key.is_a?(String)
|
data/lib/github/sql.rb
CHANGED
@@ -21,11 +21,18 @@ module GitHub
|
|
21
21
|
# * `nil` is always considered an error and not a usable value. If you need a
|
22
22
|
# SQL NULL, use the NULL constant instead.
|
23
23
|
#
|
24
|
-
# * Identical column names in SELECTs will be overridden:
|
25
|
-
# `SELECT t1.id, t2.id FROM...` will only return one value for `id`.
|
26
|
-
#
|
24
|
+
# * Identical column names in SELECTs will be overridden for hash_results:
|
25
|
+
# `SELECT t1.id, t2.id FROM...` will only return one value for `id`. The
|
26
|
+
# second ID colum won't be included in the hash:
|
27
|
+
#
|
28
|
+
# [{ "id" => "1" }]
|
29
|
+
#
|
30
|
+
# To get more than one column of the same name, use aliases:
|
27
31
|
# `SELECT t1.id t1_id, t2.id t2_id FROM ...`
|
28
32
|
#
|
33
|
+
# Calling `results` however will return an array with all the values:
|
34
|
+
# [[1, 1]]
|
35
|
+
#
|
29
36
|
# * Arrays are escaped as `(item, item, item)`. If you need to insert multiple
|
30
37
|
# rows (Arrays of Arrays), you must specify the bind value using
|
31
38
|
# GitHub::SQL::ROWS(array_of_arrays).
|
@@ -232,9 +239,9 @@ module GitHub
|
|
232
239
|
|
233
240
|
when /\ASELECT/i
|
234
241
|
# Why not execute or select_rows? Because select_all hits the query cache.
|
235
|
-
|
236
|
-
@
|
237
|
-
|
242
|
+
ar_results = connection.select_all(query, "#{self.class.name} Select")
|
243
|
+
@hash_results = ar_results.to_ary
|
244
|
+
@results = ar_results.rows
|
238
245
|
else
|
239
246
|
@results = connection.execute(query, "#{self.class.name} Execute").to_a
|
240
247
|
end
|
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.9
|
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:
|
12
|
+
date: 2018-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- LICENSE.txt
|
148
148
|
- README.md
|
149
149
|
- Rakefile
|
150
|
+
- docker-compose.yml
|
150
151
|
- examples/example_setup.rb
|
151
152
|
- examples/kv.rb
|
152
153
|
- examples/result.rb
|
@@ -191,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
192
|
version: '0'
|
192
193
|
requirements: []
|
193
194
|
rubyforge_project:
|
194
|
-
rubygems_version: 2.5
|
195
|
+
rubygems_version: 2.4.5
|
195
196
|
signing_key:
|
196
197
|
specification_version: 4
|
197
198
|
summary: A collection of libraries for working with SQL on top of ActiveRecord's connection.
|