directiverecord 0.1.25 → 0.1.26

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
2
  SHA1:
3
- metadata.gz: 5542ba11ccbf51ecb247505811188c00fd200e83
4
- data.tar.gz: c2f672c63f3d1d8ff021337ef5ef6e75bd334157
3
+ metadata.gz: bc26fa9710b00e61650bf32c723af7b687a82b09
4
+ data.tar.gz: 81ad26f3c3e8d3724c3d811f0ce4716a48743b95
5
5
  SHA512:
6
- metadata.gz: 3984980a4f9574c032c46e84dba0d638534ff1906956ac235839f215b71be7e16bbfe7dbeb1a66804a8db010bd292fd82480d19f103cc6a4c042e1db5eb48b25
7
- data.tar.gz: edcdfaebee1ab54f5ebcf528751b7439fd74bbd628760530649bd59aadc962f00a7dafb5c742c68faa6545e0fa73a6c3336c1dbd1d508feddda3a5be6c97ae0a
6
+ metadata.gz: 777881c9461b0e2596f1e355508cfe9e6b8306c3c7a0c2af94a0a87816a21074a38398426af5301477193087013404ec0261461b5c5fe319913ff724abab930c
7
+ data.tar.gz: ef1bdb1dce944f4927a1ad83c8706270d655006d48f5981b5d769a0c366aceb52ff2c821bffc5e8c954ffee8cbed5108b7707a0fe403a82e2c6c60b14aa33f5c
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  = DirectiveRecord CHANGELOG
2
2
 
3
+ == Version 0.1.26 (June 9, 2015)
4
+
5
+ * Fixed error when optimizing a query containing an ordered calculated column
6
+
3
7
  == Version 0.1.25 (May 20, 2015)
4
8
 
5
9
  * Not assuming that an ActiveRelation where value contains a table alias to a corresponding association
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.25
1
+ 0.1.26
@@ -93,7 +93,9 @@ SQL
93
93
  def optimize_query!(options)
94
94
  select = options[:select]
95
95
  if options[:optimize] && (select != %w(id)) && select.any?{|x| x.match(/^\w+(\.\w+)+$/)}
96
- ids = base.connection.select_values(to_sql(options.merge(:select => "id"))).uniq + [0]
96
+ order_by = options[:order_by] || []
97
+ select = ["id"] + select.select{|x| x.match(/ AS (\w+)$/) && order_by.any?{|y| y.include?(quote_alias($1))}}
98
+ ids = base.connection.select_values(to_sql(options.merge(:select => select))).uniq + [0]
97
99
  options[:where] = ["id IN (#{ids.join(", ")})"]
98
100
  options.delete :limit
99
101
  options.delete :offset
@@ -1,7 +1,7 @@
1
1
  module DirectiveRecord
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- TINY = 25
4
+ TINY = 26
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: directiverecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.25
4
+ version: 0.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Engel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-20 00:00:00.000000000 Z
11
+ date: 2015-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  version: '0'
207
207
  requirements: []
208
208
  rubyforge_project:
209
- rubygems_version: 2.4.3
209
+ rubygems_version: 2.2.2
210
210
  signing_key:
211
211
  specification_version: 4
212
212
  summary: A layer on top of ActiveRecord for using paths within queries without thinking