find_with_order 1.2.0 → 1.2.1

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: 3024d02ad143449be88b240808017c7ab38500b3
4
- data.tar.gz: d65519466c2eee4e8cd41e3d887d8368c5af9e67
3
+ metadata.gz: aec05deede53b157157aebfd7a0b5db7708c71ac
4
+ data.tar.gz: 210967754d0af4fd368cb9105583a349a17fe51c
5
5
  SHA512:
6
- metadata.gz: 26c9c3b58f458a24bd87c90d4caa869aa9c09f28f26dd1409dd22a877b105f2aab24f413dc95d09931bc064aa89e9e97f1074d0839f2569934972187c36aed50
7
- data.tar.gz: 9d16130c3d37aa9f69eaabd2e61684392cca820a7708bc75a0d9043a24cca3e382c70211385d8618e5e2acd60cad5e7c56e3b97b4ba7b1e5f7a3147b090eafa2
6
+ metadata.gz: dfcc2f505f41164453f9db0cb0992391c5bcdae7f785b3f23a71f0eecbc2c0325ce7929ad39fe08448f3f5b0258316be77b97ca8ab57493eae8cd80e0a73b4ce
7
+ data.tar.gz: 34f1b9bf4ca9d69f42fe34730e5a434f2e5e003521fb1fbdc27988cf682a643c38cc6a923133d58054d6a75481b309cb504184a7f1ca9d32f52ccaf9c8199da4
@@ -11,6 +11,11 @@ module FindWithOrder::MysqlSupport
11
11
  end
12
12
 
13
13
  def with_order(relation, column, ids, null_first: false)
14
+ if column.is_a?(Symbol) and relation.column_names.include?(column.to_s)
15
+ column = "#{relation.connection.quote_table_name(relation.table_name)}.#{relation.connection.quote_column_name(column)}"
16
+ else
17
+ column = column.to_s
18
+ end
14
19
  return relation.order("field(#{column}, #{ids.map(&:inspect).join(',')})") if null_first
15
20
  return relation.order("field(#{column}, #{ids.reverse.map(&:inspect).join(',')}) DESC")
16
21
  end
@@ -12,6 +12,11 @@ module FindWithOrder::PGSupport
12
12
  end
13
13
 
14
14
  def with_order(relation, column, ids, null_first: false)
15
+ if column.is_a?(Symbol) and relation.column_names.include?(column.to_s)
16
+ column = "#{relation.connection.quote_table_name(relation.table_name)}.#{relation.connection.quote_column_name(column)}"
17
+ else
18
+ column = column.to_s
19
+ end
15
20
  ids = ids.reverse if null_first
16
21
  case ids.first
17
22
  when Numeric
@@ -1,3 +1,3 @@
1
1
  module FindWithOrder
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: find_with_order
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - khiav reoy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-02 00:00:00.000000000 Z
11
+ date: 2017-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 2.6.8
141
+ rubygems_version: 2.6.13
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: A simple way to find records in the same order of input array.