constant_table_saver 6.0.0 → 6.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e78104699209fe095295ffd69d23cebca7de8c886dca5240813ee6c905e3bc2
4
- data.tar.gz: 4e012a091a754f8808088396d02c5af246dcf2374bd2c0863b2022fd721e6554
3
+ metadata.gz: 3439491d2c0407e721feb9f068213d83278391d6fca8c93c29ca3fc147902c37
4
+ data.tar.gz: 2fa2009f42c977f20eedf9fa3e11e841249250afc388f49e23d1f172b75a0d11
5
5
  SHA512:
6
- metadata.gz: 5cc34704747611b3fe9b01397d1e2796c658bfb50e79b032e6544e57256111d7a71349f87a7537dcd877df607cfc8e3efcc9bc45d971ea06f4453af013ecd713
7
- data.tar.gz: 166283c4290fd6c55e7fd884231b595b0616ac3606609de00fa09b3fa8c815210503172c3d81eda9b7f46643e33eb7a7606092f6d6183955069d3d47c20858cb
6
+ metadata.gz: 62723639d7273610e9210e411be9be75a1a50c52e995d54ed4d4a8933e127d29ce9ed30f3521a9ae4d97dc7f6b68b1ca0535a33c64afae9d4d36c1523f90da5f
7
+ data.tar.gz: 3f3a6ae939f87669cc844e83d586d5dd224356344bc5f7a5c9a19b7c00be76468d65c146d13c6614defa9b79001b6481331e2f22b37bd7cc8c2f222bc6abf108
@@ -0,0 +1,14 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ dist: bionic
6
+ rvm:
7
+ - 2.6
8
+ services:
9
+ - postgresql
10
+ - mysql
11
+ before_script:
12
+ - createdb -U postgres columns_on_demand_test
13
+ - mysqladmin -u root create columns_on_demand_test
14
+ script: ./test_all.sh
data/Gemfile CHANGED
@@ -13,8 +13,6 @@ gemspec
13
13
  gem 'rails', ENV['RAILS_VERSION']
14
14
 
15
15
  # see notes in the gemspec
16
- if ENV['RAILS_VERSION'] =~ /^[45]/
17
- gem "mysql2", "~> 0.4.10"
18
- gem "pg", "~> 0.21.0"
16
+ if ENV['RAILS_VERSION'] =~ /^5\.0/
19
17
  gem "sqlite3", "~> 1.3.6"
20
18
  end
data/README.md CHANGED
@@ -11,9 +11,7 @@ named after the name field you specify.
11
11
  Compatibility
12
12
  =============
13
13
 
14
- Currently tested against Rails 5.2 (up to 5.2.1 and 5.2.2rc1), 5.1 (up to 5.1.6), 5.0 (up to 5.0.6), and 4.2 (up to 4.2.10).
15
-
16
- For earlier versions of Rails, use an older version of the gem.
14
+ Currently tested against Rails 6.1.0.rc1, 6.0.3.4, 5.2.4.4, 5.1.7, and 5.0.7.2, with older gem versions compatible with earlier Rails versions.
17
15
 
18
16
 
19
17
  Example
@@ -11,14 +11,6 @@ cached (and frozen) records for all find calls.
11
11
 
12
12
  Optionally, creates class-level methods you can use to grab the records,
13
13
  named after the name field you specify.
14
-
15
-
16
- Compatibility
17
- =============
18
-
19
- Currently tested against Rails 5.2 (up to 5.2.1), 5.1 (up to 5.1.6) and 5.0 (up to 5.0.6) and 4.2 (up to 4.2.10).
20
-
21
- For earlier versions of Rails, use an older version of the gem.
22
14
  EOF
23
15
  gem.author = "Will Bryant"
24
16
  gem.email = "will.bryant@gmail.com"
@@ -73,20 +73,22 @@ module ConstantTableSaver
73
73
  def find_by_sql(sql, binds = [], preparable: nil, &block)
74
74
  @cached_records ||= super(relation.to_sql, &nil).each(&:freeze).freeze
75
75
 
76
+ # to_sql_and_binds returns [sql, binds] prior to 6.1, and [sql, binds, preparable] on 6.1. we take the [0..1] slice
77
+ # to ignore the preparable flag, which is useful metadata for adapters but not required for us to match statements.
76
78
  @cached_results ||= @cached_records.each_with_object({
77
79
  # matches .all queries:
78
- to_sql_and_binds(relation) => @cached_records,
80
+ to_sql_and_binds(relation)[0..1] => @cached_records,
79
81
 
80
82
  # matches .first queries:
81
- to_sql_and_binds(relation.order(relation.table[primary_key].asc).limit(1).arel) => [@cached_records.first].compact,
83
+ to_sql_and_binds(relation.order(relation.table[primary_key].asc).limit(1).arel)[0..1] => [@cached_records.first].compact,
82
84
 
83
85
  # matches .last queries:
84
- to_sql_and_binds(relation.order(relation.table[primary_key].desc).limit(1).arel) => [@cached_records.last].compact,
86
+ to_sql_and_binds(relation.order(relation.table[primary_key].desc).limit(1).arel)[0..1] => [@cached_records.last].compact,
85
87
  }) do |record, results|
86
- results[to_sql_and_binds(relation.where(relation.table[primary_key].eq(relation.predicate_builder.build_bind_attribute(primary_key, record.id))).limit(1).arel)] = [record]
88
+ results[to_sql_and_binds(relation.where(relation.table[primary_key].eq(relation.predicate_builder.build_bind_attribute(primary_key, record.id))).limit(1).arel)[0..1]] = [record]
87
89
  end.freeze
88
90
 
89
- sql_and_binds = to_sql_and_binds(sql, binds)
91
+ sql_and_binds = to_sql_and_binds(sql, binds)[0..1]
90
92
  sql_and_binds = [sql_and_binds.first, []] unless connection.prepared_statements
91
93
 
92
94
  if results = @cached_results[sql_and_binds]
@@ -1,3 +1,3 @@
1
1
  module ConstantTableSaver
2
- VERSION = '6.0.0'
2
+ VERSION = '6.1.0'
3
3
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'yaml'
4
4
 
5
- rails_versions = ["6.0.0", "5.2.0".."5.2.3", "5.1.1".."5.1.6", "5.0.2".."5.0.6", "4.2.10"].flat_map {|spec| Array(spec).collect {|v| v.gsub /.0(\d)/, '.\\1'}}
5
+ rails_versions = ["6.1.0.rc1", "6.0.3.4 ", "5.2.4.4", "5.1.7", "5.0.7.2"].flat_map {|spec| Array(spec).collect {|v| v.gsub /.0(\d)/, '.\\1'}}
6
6
  rails_envs = YAML.load(File.read("test/database.yml")).keys
7
7
 
8
8
  rails_versions.each do |version|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constant_table_saver
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Bryant
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-19 00:00:00.000000000 Z
11
+ date: 2020-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -100,20 +100,13 @@ description: |
100
100
 
101
101
  Optionally, creates class-level methods you can use to grab the records,
102
102
  named after the name field you specify.
103
-
104
-
105
- Compatibility
106
- =============
107
-
108
- Currently tested against Rails 5.2 (up to 5.2.1), 5.1 (up to 5.1.6) and 5.0 (up to 5.0.6) and 4.2 (up to 4.2.10).
109
-
110
- For earlier versions of Rails, use an older version of the gem.
111
103
  email: will.bryant@gmail.com
112
104
  executables: []
113
105
  extensions: []
114
106
  extra_rdoc_files: []
115
107
  files:
116
108
  - ".gitignore"
109
+ - ".travis.yml"
117
110
  - Dockerfile
118
111
  - Gemfile
119
112
  - MIT-LICENSE
@@ -135,7 +128,7 @@ homepage: http://github.com/willbryant/constant_table_saver
135
128
  licenses:
136
129
  - MIT
137
130
  metadata: {}
138
- post_install_message:
131
+ post_install_message:
139
132
  rdoc_options: []
140
133
  require_paths:
141
134
  - lib
@@ -150,9 +143,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
143
  - !ruby/object:Gem::Version
151
144
  version: '0'
152
145
  requirements: []
153
- rubyforge_project:
154
- rubygems_version: 2.7.6
155
- signing_key:
146
+ rubygems_version: 3.0.3
147
+ signing_key:
156
148
  specification_version: 4
157
149
  summary: Caches the records from fixed tables, and provides convenience methods to
158
150
  get them.