From 0cfcebe4c399fae8b5624235ba4641fc2c4ba153 Mon Sep 17 00:00:00 2001 From: Chris Oliver Date: Fri, 12 Mar 2021 23:02:04 -0600 Subject: [PATCH] Safely handle when database or table doesn't exist --- CHANGELOG.md | 4 ++++ Gemfile.lock | 2 +- gemfiles/rails_6.gemfile.lock | 2 +- gemfiles/rails_6_1.gemfile.lock | 2 +- gemfiles/rails_master.gemfile.lock | 2 +- lib/noticed/model.rb | 4 ++++ lib/noticed/version.rb | 2 +- 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 492c4789..33052b05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ### Unreleased +# 1.3.1 + +* Safely handle choosing coder when database or table doesn't exist - @excid3 + # 1.3.0 * Add `has_noticed_notifications` helper for models - @excid3 diff --git a/Gemfile.lock b/Gemfile.lock index 2a5d2da8..b276c474 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - noticed (1.3.0) + noticed (1.3.1) http (>= 4.0.0) rails (>= 6.0.0) diff --git a/gemfiles/rails_6.gemfile.lock b/gemfiles/rails_6.gemfile.lock index 09304c63..6f8e66be 100644 --- a/gemfiles/rails_6.gemfile.lock +++ b/gemfiles/rails_6.gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: .. specs: - noticed (1.3.0) + noticed (1.3.1) http (>= 4.0.0) rails (>= 6.0.0) diff --git a/gemfiles/rails_6_1.gemfile.lock b/gemfiles/rails_6_1.gemfile.lock index 7f581390..c5d66e25 100644 --- a/gemfiles/rails_6_1.gemfile.lock +++ b/gemfiles/rails_6_1.gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: .. specs: - noticed (1.3.0) + noticed (1.3.1) http (>= 4.0.0) rails (>= 6.0.0) diff --git a/gemfiles/rails_master.gemfile.lock b/gemfiles/rails_master.gemfile.lock index 72b894e4..a5a3f00a 100644 --- a/gemfiles/rails_master.gemfile.lock +++ b/gemfiles/rails_master.gemfile.lock @@ -97,7 +97,7 @@ GIT PATH remote: .. specs: - noticed (1.3.0) + noticed (1.3.1) http (>= 4.0.0) rails (>= 6.0.0) diff --git a/lib/noticed/model.rb b/lib/noticed/model.rb index 116d222f..50c5fc32 100644 --- a/lib/noticed/model.rb +++ b/lib/noticed/model.rb @@ -24,12 +24,16 @@ def mark_as_unread! end def noticed_coder + return Noticed::TextCoder unless table_exists? + case attribute_types["params"].type when :json, :jsonb Noticed::Coder else Noticed::TextCoder end + rescue ActiveRecord::NoDatabaseError + Noticed::TextCoder end end diff --git a/lib/noticed/version.rb b/lib/noticed/version.rb index 59ab2a72..1a193b8e 100644 --- a/lib/noticed/version.rb +++ b/lib/noticed/version.rb @@ -1,3 +1,3 @@ module Noticed - VERSION = "1.3.0" + VERSION = "1.3.1" end