localizable_db 1.0.6 → 1.0.7

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
  SHA256:
3
- metadata.gz: dee1d606b29733bb8654449c723e606fcdb5ac94c3c9e09b6d18f13599ef6113
4
- data.tar.gz: 4ef4208c4a2ff9985dca5d3400aa17f327bb7debd9ed46909a3a573ec8374346
3
+ metadata.gz: 2417072f63e592da31beda3d43c51ee0892687e285523983a8def07561c7c30c
4
+ data.tar.gz: 7382beda5c96256617bc0f2a756ece69fa24a0d00d7f474b32637d13f8f848f5
5
5
  SHA512:
6
- metadata.gz: e0245602e69ff7f44014edc0c02eafe57c6c680bd8ae7e390c9d17360441d4c671009645717c12c6915cf95f3aa989c9459cff371c26341233cff0fea4b8259b
7
- data.tar.gz: a7a51028caf72158a145b1e9b6b6fc9ddcbf77a09993f78742be1dae560e9c0324a5a1cef19fed9233ec6b1843d14edab716d32cdd8e3f74cf9ca374ffb74de3
6
+ metadata.gz: df29f593085bac7f529115270766a118791546ae4af0957241d660a149a77b46caa91cc882aad4972f024f86bf3e7116a18de016e8f8f4561f09b5dac42913c3
7
+ data.tar.gz: 2e83139d802a037df6069c19e87befb3af3829168bd3d38579eb2cfb4ad88999dd27287622201ab38429c55215765248f48a30320dafb6cdea4e549c7d07871e
@@ -144,7 +144,8 @@ module LocalizableDb
144
144
 
145
145
  def with_languages(*with_languages)
146
146
  with_languages.flatten!
147
- with_languages = LocalizableDb::Languages::SUPPORTED if with_languages.empty?
147
+ with_languages = with_languages - [LocalizableDb::Languages::DEFAULT] if with_languages.any?
148
+ with_languages = (LocalizableDb::Languages::SUPPORTED - [LocalizableDb::Languages::DEFAULT]) if with_languages.empty?
148
149
  attrs_to_select = "#{self.table_name}.*, "
149
150
  tables_to_select = "#{self.table_name}, "
150
151
  conditions_to_select = ""
@@ -154,13 +155,13 @@ module LocalizableDb
154
155
  conditions_to_select += "#{language.to_s}_#{self.localized_table_name}.locale = '#{language.to_s}' AND "
155
156
  conditions_to_select += "#{language.to_s}_#{self.localized_table_name}.localizable_object_id = #{self.table_name}.id "
156
157
  attrs_to_select += ", " if localized_attribute != self.localized_attributes.last
157
- conditions_to_select += "AND " if language != with_languages.last
158
+ conditions_to_select += "AND " if language != with_languages.last or localized_attribute != self.localized_attributes.last
158
159
  end
159
160
  tables_to_select += "#{self.localized_table_name} as #{language.to_s}_#{self.localized_table_name}"
160
161
  attrs_to_select += ", " if language != with_languages.last
161
162
  tables_to_select += ", " if language != with_languages.last
162
163
  end
163
- result = unscope(:joins)
164
+ result = unscope(:joins).unscope(:select)
164
165
  .select(attrs_to_select)
165
166
  .from(tables_to_select)
166
167
  .where(conditions_to_select)
@@ -1,3 +1,3 @@
1
1
  module LocalizableDb
2
- VERSION = '1.0.6'
2
+ VERSION = '1.0.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localizable_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - yonga9121
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-09 00:00:00.000000000 Z
12
+ date: 2018-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails