Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #15699 from sgrif/sg-4-1-custom-types

User defined types should not raise an error

Conflicts:
	activerecord/CHANGELOG.md
  • Loading branch information...
commit c361123b726b9ed4ad4a1123cabad109ebf67547 1 parent 7545b27
@matthewd matthewd authored
View
6 activerecord/CHANGELOG.md
@@ -1,3 +1,9 @@
+* Don't error when quoting user defined types in PostgreSQL.
+
+ Fixes #15697.
+
+ *Sean Griffin*
+
* `ActiveRecord::FinderMethods.find` with block can handle proc parameter as
`Enumerable#find` does.
View
2  activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
@@ -16,7 +16,7 @@ def unescape_bytea(value)
# Quotes PostgreSQL-specific data types for SQL input.
def quote(value, column = nil) #:nodoc:
- return super unless column
+ return super unless column && column.type
sql_type = type_to_sql(column.type, column.limit, column.precision, column.scale)
View
28 activerecord/test/cases/adapters/postgresql/custom_domain_test.rb
@@ -0,0 +1,28 @@
+require 'cases/helper'
+
+class PostgreSQLCustomDomainTest < ActiveRecord::TestCase
+ class CustomDomain < ActiveRecord::Base
+ end
+
+ setup do
+ @connection = ActiveRecord::Base.connection
+ @connection.execute "CREATE DOMAIN password AS TEXT"
+ @connection.create_table :custom_domains do |t|
+ t.column :passwd, 'password'
+ end
+ end
+
+ teardown do
+ if @connection
+ @connection.execute 'DROP TABLE IF EXISTS custom_domains'
+ @connection.execute 'DROP DOMAIN IF EXISTS password'
+ end
+ end
+
+ test "custom domain types do not create errors" do
+ silence_warnings do
+ record = CustomDomain.create!(passwd: 'password')
+ assert_equal record.id, CustomDomain.where(passwd: 'password').last.id
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.