semanticart-is_paranoid 0.9.3 → 0.9.4

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.
data/CHANGELOG CHANGED
@@ -1,5 +1,8 @@
1
1
  This will only document major changes. Please see the commit log for minor changes.
2
2
 
3
+ -2009-09-17
4
+ * fixed when primary key was not "id" (ie: "uuid") via Thibaud Guillaume-Gentil
5
+
3
6
  -2009-09-15
4
7
  * added support for has_many associations (i.e. @r2d2.components_with_destroyed) via Amiel Martin
5
8
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 9
3
- :patch: 3
3
+ :patch: 4
4
4
  :major: 0
data/is_paranoid.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{is_paranoid}
8
- s.version = "0.9.3"
8
+ s.version = "0.9.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeffrey Chupp"]
12
- s.date = %q{2009-09-15}
12
+ s.date = %q{2009-09-17}
13
13
  s.description = %q{}
14
14
  s.email = %q{jeff@semanticart.com}
15
15
  s.extra_rdoc_files = [
data/lib/is_paranoid.rb CHANGED
@@ -60,8 +60,8 @@ module IsParanoid
60
60
  options.reverse_merge!({:include_destroyed_dependents => true}) unless options[:include]
61
61
  with_exclusive_scope do
62
62
  update_all(
63
- "#{destroyed_field} = #{connection.quote(field_not_destroyed)}",
64
- "id = #{id}"
63
+ "#{destroyed_field} = #{connection.quote(field_not_destroyed)}",
64
+ primary_key.to_sym => id
65
65
  )
66
66
  end
67
67
 
@@ -212,7 +212,7 @@ module IsParanoid
212
212
  def destroy_without_callbacks
213
213
  self.class.update_all(
214
214
  "#{destroyed_field} = #{self.class.connection.quote(( field_destroyed.respond_to?(:call) ? field_destroyed.call : field_destroyed))}",
215
- "id = #{self.id}"
215
+ self.class.primary_key.to_sym => self.id
216
216
  )
217
217
  self
218
218
  end
@@ -281,4 +281,12 @@ describe IsParanoid do
281
281
  end
282
282
 
283
283
  end
284
+
285
+ describe "alternate primary key" do
286
+ it "should destroy without problem" do
287
+ uuid = Uuid.create(:name => "foo")
288
+ uuid.destroy.should be_true
289
+ end
290
+ end
291
+
284
292
  end
data/spec/models.rb CHANGED
@@ -91,4 +91,14 @@ class UndestroyablePirate < ActiveRecord::Base #:nodoc:
91
91
  def before_destroy
92
92
  false
93
93
  end
94
- end
94
+ end
95
+
96
+ class Uuid < ActiveRecord::Base #:nodoc:
97
+ set_primary_key "uuid"
98
+
99
+ def before_create
100
+ self.uuid = "295b3430-85b8-012c-cfe4-002332cf7d5e"
101
+ end
102
+
103
+ is_paranoid
104
+ end
data/spec/schema.rb CHANGED
@@ -48,4 +48,11 @@ ActiveRecord::Schema.define(:version => 20090317164830) do
48
48
  t.string "name"
49
49
  t.boolean "alive", :default => true
50
50
  end
51
+
52
+ create_table "uuids", :id => false, :force => true do |t|
53
+ t.string "uuid", :limit => 36, :primary => true
54
+ t.string "name"
55
+ t.datetime "deleted_at"
56
+ end
57
+
51
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semanticart-is_paranoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Chupp
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-15 00:00:00 -07:00
12
+ date: 2009-09-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15