Skip to content

Commit 0efa046

Browse files
prathamesh-sonpatkikares
authored andcommitted
Update postgres adapter column definition with cast_type
1 parent a8291d6 commit 0efa046

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/arjdbc/postgresql/adapter.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,7 @@ def index_name_length
10811081
# Returns the list of all column definitions for a table.
10821082
def columns(table_name, name = nil)
10831083
klass = ::ActiveRecord::ConnectionAdapters::PostgreSQLColumn
1084+
pass_cast_type = respond_to?(:lookup_cast_type)
10841085
column_definitions(table_name).map do |row|
10851086
# name, type, default, notnull, oid, fmod
10861087
name = row[0]; type = row[1]; default = row[2]
@@ -1094,7 +1095,12 @@ def columns(table_name, name = nil)
10941095
elsif default =~ /^\(([-+]?[\d\.]+)\)$/ # e.g. "(-1)" for a negative default
10951096
default = $1
10961097
end
1097-
klass.new(name, default, oid, type, ! notnull, fmod, self)
1098+
if pass_cast_type
1099+
cast_type = lookup_cast_type(type)
1100+
klass.new(name, default, cast_type, type, ! notnull, fmod, self)
1101+
else
1102+
klass.new(name, default, oid, type, ! notnull, fmod, self)
1103+
end
10981104
end
10991105
end
11001106

0 commit comments

Comments
 (0)