activerecord-hierarchical_query 0.1.2 → 0.1.3

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: c51bb399108f367e30e8bde8ea46171451212228
4
- data.tar.gz: 385d34aa8caa4777f50e0a2c8a7b9d84c0c30dd1
3
+ metadata.gz: b3857ae3686fc8bc70d3fa51f68ce8b179c74565
4
+ data.tar.gz: 8ff21aff761065bdc8fe7af742607a53f1488b7f
5
5
  SHA512:
6
- metadata.gz: d3bad1f4d790f159e86c1870184e43afc7b3c196394b8330d52b8cd25a582ba098b609cf2193213017838fb426f2cdebf22c53ce8b372bb211cb272c95bd7332
7
- data.tar.gz: 02b43b6cfb15595885d4d326b6ddd6cced8c34fc7d8dff3c7c1aa11eca5119852276b7d3238f78f13f6634bc9fd62b8e5eaf72505a30aff1f201d4c50d60b731
6
+ metadata.gz: 47ba81111606890e77d4decb8b1dcb8e9f10ae0ff985b74aab7309133c159294227bed679b7d748ee644aa4646fac8eb29404bee0cdfede1689f15a35dded15b
7
+ data.tar.gz: 2d474936f08750e56f9a467d07ef8bc110e099154907f260f31f579ffed75690c9f70c384e6ca3cc48bb61f56706a26ef1f06298808a1fba77cec5576b66f0ca
data/README.md CHANGED
@@ -65,7 +65,7 @@ crumbs = records.pluck(:name).join(' / ')
65
65
 
66
66
  ## Requirements
67
67
 
68
- * ActiveRecord >= 3.1.0 (Rails 4.2 included)
68
+ * ActiveRecord >= 3.1.0 (Rails 5.0 not supported yet)
69
69
  * PostgreSQL >= 8.4
70
70
 
71
71
  ## Installation
@@ -101,7 +101,12 @@ module ActiveRecord
101
101
  table = order_attribute.relation
102
102
 
103
103
  if table.engine == ActiveRecord::Base
104
- columns = table.engine.connection_pool.columns_hash[table.name]
104
+ columns =
105
+ if table.engine.connection.respond_to?(:schema_cache)
106
+ table.engine.connection.schema_cache.columns_hash(table.name)
107
+ else
108
+ table.engine.connection_pool.columns_hash[table.name]
109
+ end
105
110
  else
106
111
  columns = table.engine.columns_hash
107
112
  end
@@ -110,4 +115,4 @@ module ActiveRecord
110
115
  end
111
116
  end
112
117
  end
113
- end
118
+ end
@@ -253,7 +253,7 @@ module ActiveRecord
253
253
  #
254
254
  # @return [Arel::Table]
255
255
  def prior
256
- @recursive_table ||= Arel::Table.new("#{table.name}__recursive")
256
+ @recursive_table ||= Arel::Table.new("#{normalized_table_name}__recursive")
257
257
  end
258
258
  alias_method :previous, :prior
259
259
  alias_method :recursive_table, :prior
@@ -308,7 +308,7 @@ module ActiveRecord
308
308
  raise 'Recursive query requires CONNECT BY clause, please use #connect_by method' unless
309
309
  connect_by_value
310
310
 
311
- table_alias = join_options.fetch(:as, "#{table.name}__recursive")
311
+ table_alias = join_options.fetch(:as, "#{normalized_table_name}__recursive")
312
312
 
313
313
  JoinBuilder.new(self, relation, table_alias, join_options).build
314
314
  end
@@ -325,6 +325,10 @@ module ActiveRecord
325
325
  end.reduce(:and)
326
326
  end
327
327
  end
328
+
329
+ def normalized_table_name
330
+ table.name.gsub('.', '_')
331
+ end
328
332
  end # class Builder
329
333
  end # module HierarchicalQuery
330
334
  end # module ActiveRecord
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module HierarchicalQuery
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
@@ -0,0 +1 @@
1
+ require 'active_record/hierarchical_query'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-hierarchical_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexei Mikhailov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-18 00:00:00.000000000 Z
11
+ date: 2016-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -120,6 +120,7 @@ files:
120
120
  - lib/active_record/hierarchical_query/orderings.rb
121
121
  - lib/active_record/hierarchical_query/query.rb
122
122
  - lib/active_record/hierarchical_query/version.rb
123
+ - lib/activerecord-hierarchical_query.rb
123
124
  - lib/arel/nodes/postgresql.rb
124
125
  - spec/active_record/hierarchical_query_spec.rb
125
126
  - spec/database.travis.yml