Skip to content

Commit 6dfb7d9

Browse files
authored
Add sqlserver support (#451)
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
1 parent f52e870 commit 6dfb7d9

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
### Unreleased
22

3+
* Set `:json` type on `:params` column with default to better integrate with ActiveRecord.
4+
This fixes sqlserver (and probably other databases). #451
5+
36
### 2.3.1
47

58
* Skip `ApplicationNotifier` in generator if it already exists

app/models/concerns/noticed/deliverable.rb

-11
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@ module Deliverable
66
class_attribute :bulk_delivery_methods, instance_writer: false, default: {}
77
class_attribute :delivery_methods, instance_writer: false, default: {}
88
class_attribute :required_param_names, instance_writer: false, default: []
9-
10-
attribute :params, default: {}
11-
12-
# Ephemeral notifiers cannot serialize params since they aren't ActiveRecord backed
13-
if respond_to? :serialize
14-
if Rails.gem_version >= Gem::Version.new("7.1.0.alpha")
15-
serialize :params, coder: Coder
16-
else
17-
serialize :params, Coder
18-
end
19-
end
209
end
2110

2211
class_methods do

app/models/noticed/event.rb

+11
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,16 @@ class Event < ApplicationRecord
1111
accepts_nested_attributes_for :notifications
1212

1313
scope :newest_first, -> { order(created_at: :desc) }
14+
15+
attribute :params, :json, default: {}
16+
17+
# Ephemeral notifiers cannot serialize params since they aren't ActiveRecord backed
18+
if respond_to? :serialize
19+
if Rails.gem_version >= Gem::Version.new("7.1.0.alpha")
20+
serialize :params, coder: Coder
21+
else
22+
serialize :params, Coder
23+
end
24+
end
1425
end
1526
end

0 commit comments

Comments
 (0)