From 57c6a25357fe22bf624eaa58dced626d2450d750 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 16 Oct 2017 15:46:41 +0200 Subject: [PATCH] Improved error handling. If string in invalid charset (e. g. on binary fields), .blank? will fail (call it later). --- .../application_model/checks_attribute_values_and_length.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/application_model/checks_attribute_values_and_length.rb b/app/models/application_model/checks_attribute_values_and_length.rb index d6739a14d..2cc92eeda 100644 --- a/app/models/application_model/checks_attribute_values_and_length.rb +++ b/app/models/application_model/checks_attribute_values_and_length.rb @@ -18,7 +18,6 @@ module ApplicationModel::ChecksAttributeValuesAndLength def check_attribute_values_and_length columns = self.class.columns_hash attributes.each do |name, value| - next if value.blank? next if !value.instance_of?(String) column = columns[name] next if !column @@ -27,6 +26,8 @@ module ApplicationModel::ChecksAttributeValuesAndLength self[name].force_encoding('BINARY') end + next if value.blank? + # strip null byte chars (postgresql will complain about it) if column.type == :text if Rails.application.config.db_null_byte == false