From e844e6ed654e48b1d52bd75b4e6ab6257169aae2 Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Tue, 21 Jun 2016 16:28:14 +0200 Subject: [PATCH 1/2] sequel integration: fixing fetching default state from db column (:default is db, :ruby_default is ruby) --- lib/state_machine/integrations/sequel.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/state_machine/integrations/sequel.rb b/lib/state_machine/integrations/sequel.rb index 11381711..28f215cd 100644 --- a/lib/state_machine/integrations/sequel.rb +++ b/lib/state_machine/integrations/sequel.rb @@ -416,7 +416,7 @@ def around_validation(*) # Gets the db default for the machine's attribute def owner_class_attribute_default if owner_class.db.table_exists?(owner_class.table_name) && column = owner_class.db_schema[attribute.to_sym] - column[:default] + column[:ruby_default] end end From 6d19d1babac2f850a82218d83e37917f3e02e5c2 Mon Sep 17 00:00:00 2001 From: Tiago Cardoso Date: Tue, 21 Jun 2016 16:36:37 +0200 Subject: [PATCH 2/2] no need to literalize this, as the default is already ruby default --- lib/state_machine/integrations/sequel.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/state_machine/integrations/sequel.rb b/lib/state_machine/integrations/sequel.rb index 28f215cd..6eabf2ee 100644 --- a/lib/state_machine/integrations/sequel.rb +++ b/lib/state_machine/integrations/sequel.rb @@ -422,7 +422,7 @@ def owner_class_attribute_default # Uses the DB literal to match the default against the specified state def owner_class_attribute_default_matches?(state) - owner_class.db.literal(state.value) == owner_class_attribute_default + state.value == owner_class_attribute_default end # Creates a scope for finding records *with* a particular state or