denormalize-field 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "denormalize-field"
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Len Smith"]
12
- s.date = "2013-05-28"
12
+ s.date = "2014-01-18"
13
13
  s.description = "Denormalize ActiveRecord fields for performance reasons"
14
14
  s.email = "len@barrison.com"
15
15
  s.extra_rdoc_files = [
@@ -31,7 +31,8 @@ module DenormalizeFields
31
31
 
32
32
  _klass.after_save do
33
33
  if self.send "#{_field_name}_changed?"
34
- update_sql = "UPDATE #{_original_klass.table_name} SET #{_denormalized_field_name} = '#{self.send(_field_name)}' where #{key}_id = #{self.id}"
34
+ quoted_value = ActiveRecord::Base.connection.quote self.send(_field_name)
35
+ update_sql = "UPDATE #{_original_klass.table_name} SET #{_denormalized_field_name} = #{quoted_value} where #{key}_id = #{self.id}"
35
36
  self.connection.execute update_sql
36
37
  end
37
38
  end
@@ -39,6 +39,15 @@ describe "DenormalizeField" do
39
39
  post.category_name.should == "Sports"
40
40
  end
41
41
 
42
+ it "handles field values with quotes" do
43
+ post.save!
44
+ category = Category.first
45
+ category.name = "Champion's League"
46
+ category.save!
47
+ post.reload
48
+ post.category_name.should == "Champion's League"
49
+ end
50
+
42
51
  it "handles nil associations" do
43
52
  post.category = nil
44
53
  expect { post.save! }.to_not raise_error
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: denormalize-field
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-28 00:00:00.000000000 Z
12
+ date: 2014-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -179,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  segments:
181
181
  - 0
182
- hash: -308078005241704715
182
+ hash: -416803536568193147
183
183
  required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  none: false
185
185
  requirements: