Skip to content

Commit

Permalink
Add sqlserver support (#451)
Browse files Browse the repository at this point in the history
By specifying the type for the params column, we can make sure ActiveRecord knows how to handle this for more databases like sqlserver.

Fixes #450
  • Loading branch information
excid3 authored May 28, 2024
1 parent f52e870 commit 6dfb7d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
### Unreleased

* Set `:json` type on `:params` column with default to better integrate with ActiveRecord.
This fixes sqlserver (and probably other databases). #451

### 2.3.1

* Skip `ApplicationNotifier` in generator if it already exists
Expand Down
11 changes: 0 additions & 11 deletions app/models/concerns/noticed/deliverable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@ module Deliverable
class_attribute :bulk_delivery_methods, instance_writer: false, default: {}
class_attribute :delivery_methods, instance_writer: false, default: {}
class_attribute :required_param_names, instance_writer: false, default: []

attribute :params, default: {}

# Ephemeral notifiers cannot serialize params since they aren't ActiveRecord backed
if respond_to? :serialize
if Rails.gem_version >= Gem::Version.new("7.1.0.alpha")
serialize :params, coder: Coder
else
serialize :params, Coder
end
end
end

class_methods do
Expand Down
11 changes: 11 additions & 0 deletions app/models/noticed/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,16 @@ class Event < ApplicationRecord
accepts_nested_attributes_for :notifications

scope :newest_first, -> { order(created_at: :desc) }

attribute :params, :json, default: {}

# Ephemeral notifiers cannot serialize params since they aren't ActiveRecord backed
if respond_to? :serialize
if Rails.gem_version >= Gem::Version.new("7.1.0.alpha")
serialize :params, coder: Coder
else
serialize :params, Coder
end
end
end
end

0 comments on commit 6dfb7d9

Please sign in to comment.