aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-05-30 08:35:59 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-05-30 08:59:43 +0900
commita0d17760bbc6254e0231a42300c842501aca080e (patch)
tree01475224264859769b7719febd95d4c2bf1aec89 /activerecord/lib/active_record/connection_adapters/postgresql
parent0a9522a8b316171d083623cd9dd50f2aa21efb2c (diff)
downloadrails-a0d17760bbc6254e0231a42300c842501aca080e.tar.gz
rails-a0d17760bbc6254e0231a42300c842501aca080e.tar.bz2
rails-a0d17760bbc6254e0231a42300c842501aca080e.zip
Fix UUID column with `null: true` and `default: nil`
`quote_default_expression` can be passed nil value when `null: true` and `default: nil`. This addressed in that case. Fixes #29222.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
index da8d0c6992..44eb666965 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
@@ -62,7 +62,7 @@ module ActiveRecord
def quote_default_expression(value, column) # :nodoc:
if value.is_a?(Proc)
value.call
- elsif column.type == :uuid && value.include?("()")
+ elsif column.type == :uuid && /\(\)/.match?(value)
value # Does not quote function default values for UUID columns
elsif column.respond_to?(:array?)
value = type_cast_from_column(column, value)