Skip to content

Commit

Permalink
User defined types should not raise an error
Browse files Browse the repository at this point in the history
Fixes #15697 on 4-1-stable.
  • Loading branch information
sgrif committed Jun 13, 2014
1 parent 24adeff commit b1cae73
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
6 changes: 6 additions & 0 deletions activerecord/CHANGELOG.md
@@ -1,3 +1,9 @@
* Don't error when quoting user defined types in PostgreSQL.

Fixes #15697.

*Sean Griffin*

* Ensure both parent IDs are set on join records when both sides of a
through association are new.

Expand Down
Expand Up @@ -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)

Expand Down
28 changes: 28 additions & 0 deletions 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

0 comments on commit b1cae73

Please sign in to comment.