baby_squeel 1.2.1 → 1.4.1

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
- SHA1:
3
- metadata.gz: f491f71692c6a13ed97203fd5cf7c9b08afeac2b
4
- data.tar.gz: 5da604986d6d6478b703414f9b78307871ca8adf
2
+ SHA256:
3
+ metadata.gz: c1c744d9857aadfec2192c82fef09f2fb3f1c67765852da080bfcf3a1f5aba72
4
+ data.tar.gz: d3dfb10bcf6496c530f29a87146a53039c925cc3dc86fe9cfbced8eb8d0afd6f
5
5
  SHA512:
6
- metadata.gz: 60f3bfa7c9de2b6fdcc470a65f23e945d340d538f1dd54f19237f8844a1c5b348d8cf713d74f36e7a333dc9e836fd44ae3b234acfc57173bb1556844963065f8
7
- data.tar.gz: 5739d55d7eaf421f1091ab580cff50e263a73543ade85b4a43bab64a79342269111c988d8144daff5bb7eac72d511e38194256a124998352d2add127c19ed789
6
+ metadata.gz: 211d541b43c1117bf46f79f220c34fbe5959fbc3597440ccfc3b4565fe087192d23342d365f757bda6ed5f03ba80cfbe2b03eea6e40955489f53e5f5813bb688
7
+ data.tar.gz: 431218e9d183f1507095036417af43b3d80b2189bb0c9abab5dc9e99c995f44cd79a0965b249ae468442ce3fa7436c8b86db2258efa6531a5ed80d00f16495ee
data/CHANGELOG.md CHANGED
@@ -1,6 +1,29 @@
1
1
  ## [Unreleased]
2
2
 
3
- Nothing to see here.
3
+ ## [1.4.1] - 2021-06-17
4
+ ## Fixed
5
+ - Fixed a bug related to checking the Active Record version.
6
+
7
+ ## [1.4.0] - 2021-06-17
8
+ ## Fixed
9
+ - Fix table alias when joining a polymorphic table twice (#108)
10
+ - Removed internal class `BabySqueel::Pluck`. You can still use `plucking`. For example, `Post.joining { author }.plucking { author.name }`
11
+ - Removed old code from Active Record < 5.2
12
+ - Removed dependency `join_dependency`
13
+
14
+ ## [1.4.0.beta1] - 2021-04-21
15
+ ## Fixed
16
+ - Add Support for activerecord '>= 5.2.3'
17
+ - Drop Support for Active Record versions that have reached EOL (activerecord < 5.2)
18
+ - Use polyamorous from ransack '~> 2.3'
19
+
20
+ ## [1.3.1] - 2018-05-15
21
+ ## Fixed
22
+ - Upgraded `join_dependency` requirement, which fixes [issue #1](https://github.com/rzane/join_dependency/issues/1).
23
+
24
+ ## [1.3.0] - 2018-05-04
25
+ ## Added
26
+ - The ability to use `plucking` with an array of nodes. For example, `User.plucking { [id, name] }`.
4
27
 
5
28
  ## [1.2.1] - 2018-04-25
6
29
  ## Fixed
@@ -131,7 +154,12 @@ Nothing to see here.
131
154
  ### Added
132
155
  - Initial support for selects, orders, wheres, and joins.
133
156
 
134
- [Unreleased]: https://github.com/rzane/baby_squeel/compare/v1.2.1...HEAD
157
+ [Unreleased]: https://github.com/rzane/baby_squeel/compare/v1.4.1...HEAD
158
+ [1.4.1]: https://github.com/rzane/baby_squeel/compare/v1.4.0...v1.4.1
159
+ [1.4.0]: https://github.com/rzane/baby_squeel/compare/v1.4.0.beta1...v1.4.0
160
+ [1.4.0.beta1]: https://github.com/rzane/baby_squeel/compare/v1.3.1...v1.4.0.beta1
161
+ [1.3.1]: https://github.com/rzane/baby_squeel/compare/v1.3.0...v1.3.1
162
+ [1.3.0]: https://github.com/rzane/baby_squeel/compare/v1.2.1...v1.3.0
135
163
  [1.2.1]: https://github.com/rzane/baby_squeel/compare/v1.2.0...v1.2.1
136
164
  [1.2.0]: https://github.com/rzane/baby_squeel/compare/v1.1.5...v1.2.0
137
165
  [1.1.5]: https://github.com/rzane/baby_squeel/compare/v1.1.4...v1.1.5
data/ISSUE_TEMPLATE.md CHANGED
@@ -11,7 +11,7 @@ require 'minitest/autorun'
11
11
 
12
12
  gemfile true do
13
13
  source 'https://rubygems.org'
14
- gem 'activerecord', '~> 5.0.0' # which Active Record version?
14
+ gem 'activerecord', '~> 5.2.0' # which Active Record version?
15
15
  gem 'sqlite3'
16
16
  gem 'baby_squeel', github: 'rzane/baby_squeel'
17
17
  end
data/README.md CHANGED
@@ -1,10 +1,7 @@
1
- # BabySqueel
1
+ # BabySqueel 🐷
2
2
 
3
- [![Build Status](https://travis-ci.org/rzane/baby_squeel.svg?branch=master)](https://travis-ci.org/rzane/baby_squeel)
4
- [![Code Climate](https://codeclimate.com/github/rzane/baby_squeel/badges/gpa.svg)](https://codeclimate.com/github/rzane/baby_squeel)
5
- [![Coverage Status](https://coveralls.io/repos/github/rzane/baby_squeel/badge.svg?branch=master)](https://coveralls.io/github/rzane/baby_squeel?branch=master)
6
-
7
- <img align="right" src="http://static.thefrisky.com/uploads/2010/07/01/pig_in_boots_070110_m.jpg" alt="biddy piggy">
3
+ ![Build](https://github.com/rzane/baby_squeel/workflows/Build/badge.svg)
4
+ ![Version](https://img.shields.io/gem/v/baby_squeel)
8
5
 
9
6
  Have you ever used the [Squeel](https://github.com/activerecord-hackery/squeel) gem? It's a really nice way to build complex queries. However, Squeel monkeypatches Active Record internals, because it was aimed at enhancing the existing API with the aim of inclusion into Rails. However, that inclusion never happened, and it left Squeel susceptible to breakage from arbitrary changes in Active Record, eventually burning out the maintainer.
10
7
 
@@ -219,6 +216,21 @@ Post.joins(:author).where.has {
219
216
  # )
220
217
  ```
221
218
 
219
+ ##### Exists
220
+
221
+ ```ruby
222
+ Post.where.has {
223
+ exists Post.where.has { author_id == 1 }
224
+ }
225
+ # SELECT "posts".* FROM "posts"
226
+ # WHERE (
227
+ # EXISTS(
228
+ # SELECT "posts".* FROM "posts"
229
+ # WHERE "posts"."author_id" = 1
230
+ # )
231
+ # )
232
+ ```
233
+
222
234
  ##### Custom SQL Operators
223
235
 
224
236
  ```ruby
@@ -240,6 +252,26 @@ Post.joining {
240
252
  }
241
253
  ```
242
254
 
255
+ ##### Polymorphism
256
+
257
+ Given this polymorphism:
258
+
259
+ ```ruby
260
+ # app/models/picture.rb
261
+ belongs_to :imageable, polymorphic: true
262
+
263
+ # app/models/post.rb
264
+ has_many :pictures, as: :imageable
265
+ ```
266
+
267
+ The query might look like this:
268
+
269
+ ```ruby
270
+ Picture.
271
+ joining { imageable.of(Post) }.
272
+ selecting { imageable.of(Post).id }
273
+ ```
274
+
243
275
  ##### Helpers
244
276
 
245
277
  ```ruby
@@ -283,7 +315,7 @@ Post.joins(:author).where.has {
283
315
  The following methods give you access to BabySqueel's DSL:
284
316
 
285
317
  | BabySqueel | Active Record Equivalent |
286
- |---------------|--------------------------|
318
+ | ------------- | ------------------------ |
287
319
  | `selecting` | `select` |
288
320
  | `ordering` | `order` |
289
321
  | `joining` | `joins` |
@@ -297,7 +329,7 @@ Check out the [migration guide](https://github.com/rzane/baby_squeel/wiki/Migrat
297
329
 
298
330
  ## Development
299
331
 
300
- 1. Pick an Active Record version to develop against, then export it: `export AR=4.2.6`.
332
+ 1. Pick an Active Record version to develop against, then export it: `export AR=5.2.0`.
301
333
  2. Run `bin/setup` to install dependencies.
302
334
  3. Run `rake` to run the specs.
303
335
 
data/baby_squeel.gemspec CHANGED
@@ -19,12 +19,11 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.files = Dir.glob('{lib/**/*,*.{md,txt,gemspec}}')
21
21
 
22
- spec.add_dependency 'activerecord', '>= 4.2.0'
23
- spec.add_dependency 'polyamorous', '~> 1.3'
24
- spec.add_dependency 'join_dependency', '~> 0.1.1'
22
+ spec.add_dependency 'activerecord', '~> 5.2'
23
+ spec.add_dependency 'ransack', '~> 2.3'
25
24
 
26
- spec.add_development_dependency 'bundler', '~> 1.11'
27
- spec.add_development_dependency 'rake', '~> 10.0'
28
- spec.add_development_dependency 'rspec', '~> 3.4.0'
29
- spec.add_development_dependency 'sqlite3'
25
+ spec.add_development_dependency 'bundler', '~> 2'
26
+ spec.add_development_dependency 'rake', '~> 13.0'
27
+ spec.add_development_dependency 'rspec', '~> 3.10'
28
+ spec.add_development_dependency 'sqlite3', '~> 1.3.6'
30
29
  end
data/lib/baby_squeel.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  require 'active_record'
2
2
  require 'active_record/relation'
3
- require 'polyamorous'
3
+ begin
4
+ require 'polyamorous'
5
+ rescue LoadError
6
+ # Trying loading from 'ransack' as of commit c9cc20de9 (post v2.3.2)
7
+ require 'polyamorous/polyamorous'
8
+ end
4
9
  require 'baby_squeel/version'
5
10
  require 'baby_squeel/errors'
6
11
  require 'baby_squeel/active_record/base'
@@ -1,11 +1,11 @@
1
1
  require 'baby_squeel/calculation'
2
- require 'baby_squeel/pluck'
3
2
 
4
3
  module BabySqueel
5
4
  module ActiveRecord
6
5
  module Calculations
7
6
  def plucking(&block)
8
- pluck Pluck.wrap(DSL.evaluate(self, &block))
7
+ nodes = Array.wrap(DSL.evaluate(self, &block))
8
+ pluck(*nodes)
9
9
  end
10
10
 
11
11
  def counting(&block)
@@ -38,17 +38,6 @@ module BabySqueel
38
38
  super
39
39
  end
40
40
  end
41
-
42
- if ::ActiveRecord::VERSION::MAJOR < 5
43
- # @override
44
- def type_for(field)
45
- if field.kind_of? Calculation
46
- field
47
- else
48
- super
49
- end
50
- end
51
- end
52
41
  end
53
42
  end
54
43
  end
@@ -40,14 +40,8 @@ module BabySqueel
40
40
  # Active Record will call `group_by` on the `joins`. The
41
41
  # Injector has a custom `group_by` method that handles
42
42
  # BabySqueel::Join nodes.
43
- if ::ActiveRecord::VERSION::MAJOR >= 5 && ::ActiveRecord::VERSION::MINOR >= 2
44
- def build_joins(manager, joins, aliases)
45
- super manager, BabySqueel::JoinDependency::Injector.new(joins), aliases
46
- end
47
- else
48
- def build_joins(manager, joins)
49
- super manager, BabySqueel::JoinDependency::Injector.new(joins)
50
- end
43
+ def build_joins(manager, joins, aliases)
44
+ super manager, BabySqueel::JoinDependency::Injector.new(joins), aliases
51
45
  end
52
46
  end
53
47
  end
@@ -96,19 +96,13 @@ module BabySqueel
96
96
 
97
97
  private
98
98
 
99
- if ActiveRecord::VERSION::MAJOR >= 5
100
- def build_where_clause(other)
101
- if valid_where_clause?(other)
102
- relation = @parent._scope.all
103
- factory = relation.send(:where_clause_factory)
104
- factory.build({ _reflection.name => other }, [])
105
- else
106
- raise AssociationComparisonError.new(_reflection.name, other)
107
- end
108
- end
109
- else
110
- def build_where_clause(_)
111
- raise AssociationComparisonNotSupportedError.new(_reflection.name)
99
+ def build_where_clause(other)
100
+ if valid_where_clause?(other)
101
+ relation = @parent._scope.all
102
+ factory = relation.send(:where_clause_factory)
103
+ factory.build({ _reflection.name => other }, [])
104
+ else
105
+ raise AssociationComparisonError.new(_reflection.name, other)
112
106
  end
113
107
  end
114
108
 
@@ -6,12 +6,6 @@ module BabySqueel
6
6
  @node = node
7
7
  end
8
8
 
9
- # This is only used in 4.2. We're just pretending to be
10
- # a database column to fake the casting here.
11
- def type_cast_from_database(value)
12
- value
13
- end
14
-
15
9
  # In Active Record 5, we don't *need* this class to make
16
10
  # calculations work. They happily accept arel. However,
17
11
  # when grouping with a calculation, there's a really,
@@ -62,14 +62,4 @@ module BabySqueel
62
62
  super "You can't compare association '#{name}' to #{other}."
63
63
  end
64
64
  end
65
-
66
- class AssociationComparisonNotSupportedError < StandardError # :nodoc:
67
- MESSAGE =
68
- "Querying association '%{name}' with '==' and '!=' " \
69
- "is only supported for ActiveRecord >=5."
70
-
71
- def initialize(name)
72
- super format(MESSAGE, name: name)
73
- end
74
- end
75
65
  end
@@ -1,5 +1,3 @@
1
- require 'join_dependency'
2
-
3
1
  module BabySqueel
4
2
  module JoinDependency
5
3
  # This class allows BabySqueel to slip custom
@@ -26,52 +24,104 @@ module BabySqueel
26
24
  attr_reader :join_dependency
27
25
 
28
26
  def initialize(relation)
29
- @join_dependency = ::JoinDependency.from_relation(relation) do |join|
30
- :association_join if join.kind_of? BabySqueel::Join
31
- end
27
+ @join_dependency = build(relation, collect_joins(relation))
32
28
  end
33
29
 
34
30
  # Find the alias of a BabySqueel::Association, by passing
35
31
  # a list (in order of chaining) of associations and finding
36
32
  # the respective JoinAssociation at each level.
37
33
  def find_alias(associations)
38
- table = find_join_association(associations).table
39
- reconstruct_with_type_caster(table, associations)
34
+ # If we tell join_dependency to construct its tables, Active Record
35
+ # handles building the correct aliases and attaching them to its
36
+ # JoinDepenencies.
37
+ if at_least?("5.2.3")
38
+ join_dependency.send(:construct_tables!, join_dependency.send(:join_root))
39
+ end
40
+
41
+ join_association = find_join_association(associations)
42
+ join_association.table
40
43
  end
41
44
 
42
45
  private
43
46
 
47
+ Associations = ::ActiveRecord::Associations
48
+
44
49
  def find_join_association(associations)
45
- associations.inject(join_dependency.send(:join_root)) do |parent, assoc|
46
- parent.children.find do |join_association|
47
- reflections_equal?(
48
- assoc._reflection,
49
- join_association.reflection
50
- )
50
+ current = join_dependency.send(:join_root)
51
+
52
+ associations.each do |association|
53
+ name = association._reflection.name
54
+ current = current.children.find { |c| c.reflection.name == name && klass_equal?(association, c) }
55
+ break if current.nil?
56
+ end
57
+
58
+ current
59
+ end
60
+
61
+ # If association is not polymorphic return true.
62
+ # If association is polymorphic compare the association polymorphic class with the join association base_klass
63
+ def klass_equal?(assoc, join_association)
64
+ return true unless assoc._reflection.polymorphic?
65
+
66
+ assoc._polymorphic_klass == join_association.base_klass
67
+ end
68
+
69
+ def collect_joins(relation)
70
+ joins = []
71
+ joins += relation.joins_values
72
+ joins += relation.left_outer_joins_values if at_least?("5")
73
+
74
+ buckets = joins.group_by do |join|
75
+ case join
76
+ when String
77
+ :string_join
78
+ when Hash, Symbol, Array
79
+ :association_join
80
+ when Associations::JoinDependency
81
+ :stashed_join
82
+ when Arel::Nodes::Join
83
+ :join_node
84
+ when BabySqueel::Join
85
+ :association_join
86
+ else
87
+ raise("unknown class: %s" % join.class.name)
51
88
  end
52
89
  end
53
90
  end
54
91
 
55
- # Compare two reflections and see if they're the same.
56
- def reflections_equal?(a, b)
57
- comparable_reflection(a) == comparable_reflection(b)
92
+ def build(relation, buckets)
93
+ buckets.default = []
94
+ association_joins = buckets[:association_join]
95
+ stashed_association_joins = buckets[:stashed_join]
96
+ join_nodes = buckets[:join_node].uniq
97
+ string_joins = buckets[:string_join].map(&:strip).uniq
98
+
99
+ joins = string_joins.map do |join|
100
+ relation.table.create_string_join(Arel.sql(join)) unless join.blank?
101
+ end.compact
102
+
103
+ join_list = join_nodes + joins
104
+
105
+ alias_tracker = Associations::AliasTracker.create(relation.klass.connection, relation.table.name, join_list)
106
+ if exactly?("5.2.0")
107
+ join_dependency = Associations::JoinDependency.new(relation.klass, relation.table, association_joins, alias_tracker)
108
+ else
109
+ join_dependency = Associations::JoinDependency.new(relation.klass, relation.table, association_joins)
110
+ join_dependency.instance_variable_set(:@alias_tracker, alias_tracker)
111
+ end
112
+ join_nodes.each do |join|
113
+ join_dependency.send(:alias_tracker).aliases[join.left.name.downcase] = 1
114
+ end
115
+
116
+ join_dependency
58
117
  end
59
118
 
60
- # Get the parent of the reflection if it has one.
61
- # In AR4, #parent_reflection returns [name, reflection]
62
- # In AR5, #parent_reflection returns just a reflection
63
- def comparable_reflection(reflection)
64
- [*reflection.parent_reflection].last || reflection
119
+ def exactly?(version)
120
+ ::ActiveRecord.gem_version == Gem::Version.new(version)
65
121
  end
66
122
 
67
- # Active Record 5's AliasTracker initializes Arel tables
68
- # with the type_caster belonging to the wrong model.
69
- #
70
- # See: https://github.com/rails/rails/pull/27994
71
- def reconstruct_with_type_caster(table, associations)
72
- return table if ::ActiveRecord::VERSION::MAJOR < 5
73
- type_caster = associations.last._scope.type_caster
74
- ::Arel::Table.new(table.name, type_caster: type_caster)
123
+ def at_least?(version)
124
+ ::ActiveRecord.gem_version >= Gem::Version.new(version)
75
125
  end
76
126
  end
77
127
  end
@@ -1,3 +1,3 @@
1
1
  module BabySqueel
2
- VERSION = '1.2.1'.freeze
2
+ VERSION = '1.4.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,113 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baby_squeel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ray Zane
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-25 00:00:00.000000000 Z
11
+ date: 2021-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 4.2.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 4.2.0
27
- - !ruby/object:Gem::Dependency
28
- name: polyamorous
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '1.3'
19
+ version: '5.2'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '1.3'
26
+ version: '5.2'
41
27
  - !ruby/object:Gem::Dependency
42
- name: join_dependency
28
+ name: ransack
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: 0.1.1
33
+ version: '2.3'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: 0.1.1
40
+ version: '2.3'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: bundler
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '1.11'
47
+ version: '2'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '1.11'
54
+ version: '2'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rake
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: '10.0'
61
+ version: '13.0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '10.0'
68
+ version: '13.0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rspec
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: 3.4.0
75
+ version: '3.10'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: 3.4.0
82
+ version: '3.10'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: sqlite3
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - ">="
87
+ - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '0'
89
+ version: 1.3.6
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - ">="
94
+ - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: 1.3.6
111
97
  description: An expressive query DSL for Active Record 4 and 5.
112
98
  email:
113
99
  - ray@promptworks.com
@@ -140,7 +126,6 @@ files:
140
126
  - lib/baby_squeel/nodes/node.rb
141
127
  - lib/baby_squeel/nodes/proxy.rb
142
128
  - lib/baby_squeel/operators.rb
143
- - lib/baby_squeel/pluck.rb
144
129
  - lib/baby_squeel/relation.rb
145
130
  - lib/baby_squeel/resolver.rb
146
131
  - lib/baby_squeel/table.rb
@@ -149,7 +134,7 @@ homepage: https://github.com/rzane/baby_squeel
149
134
  licenses:
150
135
  - MIT
151
136
  metadata: {}
152
- post_install_message:
137
+ post_install_message:
153
138
  rdoc_options: []
154
139
  require_paths:
155
140
  - lib
@@ -164,9 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
149
  - !ruby/object:Gem::Version
165
150
  version: '0'
166
151
  requirements: []
167
- rubyforge_project:
168
- rubygems_version: 2.6.10
169
- signing_key:
152
+ rubygems_version: 3.0.3
153
+ signing_key:
170
154
  specification_version: 4
171
155
  summary: An expressive query DSL for Active Record 4 and 5.
172
156
  test_files: []
@@ -1,25 +0,0 @@
1
- module BabySqueel
2
- class Pluck # :nodoc:
3
- # In Active Record 4.2, #pluck chokes when you give it
4
- # Arel. It calls #to_s on whatever you pass in. So the
5
- # hacky solution is to wrap the node in a class that
6
- # returns the node when you call #to_s. Then, it works!
7
- #
8
- # In Active Record 5, #pluck accepts Arel, so we won't
9
- # bother to use this there.
10
-
11
- if ::ActiveRecord::VERSION::MAJOR >= 5
12
- def self.wrap(node); node; end
13
- else
14
- def self.wrap(node); new(node); end
15
- end
16
-
17
- def initialize(node)
18
- @node = node
19
- end
20
-
21
- def to_s
22
- @node
23
- end
24
- end
25
- end