umbrellio-sequel-plugins 0.3.0.62 → 0.3.0.67

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: 5491ca47e62aebd09d14f3cbbb576f27eeacfdaa
4
- data.tar.gz: 6589599be43f330906153fe3c48b8b862b119072
3
+ metadata.gz: d5a62467c7b304dfb4e42ca312d464c3fcfecf69
4
+ data.tar.gz: 340da5aa8aa43bd09a5a231ff66a0901baa2d647
5
5
  SHA512:
6
- metadata.gz: 14d95afdc741d64ad49c19d991c5eb4bea170e4a838ca6234e05743ab32bf5400d36b10d14944cbda632ccce856e59937ae56fa312fe4e4baf6142bef8538a42
7
- data.tar.gz: 98a9448f7a647574504dad542c584590d1ead5f2fba79573d7074fd83d713dca748a99dde1e36737fdc07dc1ec112bb4799409266521792dd73d33d4f59c3f70
6
+ metadata.gz: 86d81572f6b945e4c75fb00636b10060b2e38b940c1482dae01e1995bf691377ab1ab64f8b07c567550fde7c4b68b28435e60fc804d818c05ef5cebba991caa6
7
+ data.tar.gz: 8e8221c2e60197c269b196ef362622a8e34dffdeec4b5c35b87b4a3d04b48b855a5a85ed68d5a387726827158aa7bf9514414fc8ae84baf93f012acdb12bdbf5
@@ -7,8 +7,9 @@ module Sequel
7
7
  #
8
8
  # @param aliaz [Symbol] alias to be used for joined table
9
9
  # @param table [Symbol] table name to join to
10
- # @param currency_column [Symbol] currency column by which table is joined
11
- # @param time_column [Symbol] time column by which table is joined
10
+ # @param currency_column [Symbol or Sequel::SQL::Expression] currency column by which
11
+ # table is joined
12
+ # @param time_column [Symbol or Sequel::SQL::Expression] time column by which table is joined
12
13
  #
13
14
  # @example
14
15
  # Order::Model.with_rates.select(Sequel[:amount].in_usd)
@@ -22,8 +23,11 @@ module Sequel
22
23
  )
23
24
  table = Sequel[table]
24
25
  rates = Sequel[aliaz]
25
- join_expr = table[currency_column] =~ rates[:currency]
26
- join_expr &= rates[:period].pg_range.contains(table[time_column])
26
+
27
+ currency_expr = wrap_if_symbol(currency_column, table)
28
+ time_expr = wrap_if_symbol(time_column, table)
29
+
30
+ join_expr = (rates[:currency] =~ currency_expr) & rates[:period].pg_range.contains(time_expr)
27
31
  left_join(rates_table.as(aliaz), join_expr)
28
32
  end
29
33
 
@@ -33,6 +37,12 @@ module Sequel
33
37
  def table_name
34
38
  respond_to?(:first_source_alias) ? first_source_alias : super
35
39
  end
40
+
41
+ private
42
+
43
+ def wrap_if_symbol(column_name, table)
44
+ column_name.is_a?(Symbol) ? table[column_name] : column_name
45
+ end
36
46
  end
37
47
 
38
48
  module CurrencyRateExchange
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umbrellio-sequel-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.62
4
+ version: 0.3.0.67
5
5
  platform: ruby
6
6
  authors:
7
7
  - nulldef
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-23 00:00:00.000000000 Z
11
+ date: 2019-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel