orm_adapter 0.4.1 → 0.5.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
  SHA1:
3
- metadata.gz: cc52f312f40978e98faccf378d0478a5bc4778b0
4
- data.tar.gz: fc8d36e106c659dbac6b7f620657899c81245248
3
+ metadata.gz: c94ff61c9aabbe1129b7037d1187a29e803ebb52
4
+ data.tar.gz: cf04bc145952fb582c6015a9b85d0129d2d801cf
5
5
  SHA512:
6
- metadata.gz: 9b4889fc827dfe94918c89873dbf5b6bd9063321674115ac3990d1422be7263b8c9a777e3f1692511cd404ae31bbe292bf6eedab7e4e5231ed868258ab62991b
7
- data.tar.gz: 2833a8437efde00b070b520926d2ff42c080a9f5737db60bfe3687e766324148bfbe38cc4d5049be69a72d0169c9bec75a71ba35f3d4204a8758cb9b1e6ed752
6
+ metadata.gz: cdadd8d9a6cd0483802fc6c4f6865dd2647842c1ddbde7e078efdb413b23b98228a55c9fc95620d73029dbdfe9a3706e31371b1325d6b77eb4da612001c9f137
7
+ data.tar.gz: 9af572ba4d45256586ec8b0c49ef1e23fb55a646045c268a9cdaa02f0143539678c477fd25f6b2bd5a84f3f7e3bc8644652e0b16a854fafd7977443472953814
@@ -1,3 +1,8 @@
1
+ == 0.5.0
2
+
3
+ * Only send relation modifiers to ActiveRecord if they apply (don't send #order, #limit, #offset unless specified)
4
+ Fixes plataformatec/devise#2711, ianwhite/orm_adapter#22
5
+
1
6
  == 0.4.1
2
7
 
3
8
  * Adds activerecord 4 to the test suite
@@ -19,14 +19,12 @@ module OrmAdapter
19
19
 
20
20
  # @see OrmAdapter::Base#find_first
21
21
  def find_first(options = {})
22
- conditions, order = extract_conditions!(options)
23
- klass.where(conditions_to_fields(conditions)).order(*order_clause(order)).first
22
+ construct_relation(klass, options).first
24
23
  end
25
24
 
26
25
  # @see OrmAdapter::Base#find_all
27
26
  def find_all(options = {})
28
- conditions, order, limit, offset = extract_conditions!(options)
29
- klass.where(conditions_to_fields(conditions)).order(*order_clause(order)).limit(limit).offset(offset)
27
+ construct_relation(klass, options)
30
28
  end
31
29
 
32
30
  # @see OrmAdapter::Base#create!
@@ -40,6 +38,16 @@ module OrmAdapter
40
38
  end
41
39
 
42
40
  protected
41
+ def construct_relation(relation, options)
42
+ conditions, order, limit, offset = extract_conditions!(options)
43
+
44
+ relation = relation.where(conditions_to_fields(conditions))
45
+ relation = relation.order(order_clause(order)) if order.any?
46
+ relation = relation.limit(limit) if limit
47
+ relation = relation.offset(offset) if offset
48
+
49
+ relation
50
+ end
43
51
 
44
52
  # Introspects the klass to convert and objects in conditions into foreign key and type fields
45
53
  def conditions_to_fields(conditions)
@@ -1,3 +1,3 @@
1
1
  module OrmAdapter
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orm_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian White