activerecord-redshift-adapter 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -107,6 +107,12 @@ module ActiverecordRedshift
|
|
107
107
|
column_names[row['attnum']] = row['attname']
|
108
108
|
end
|
109
109
|
end
|
110
|
+
|
111
|
+
column_defaults = {}
|
112
|
+
sql = "select a.attname,d.adsrc from pg_attribute as a,pg_attrdef as d where a.attrelid = d.adrelid and d.adnum = a.attnum and a.attrelid = #{table_oid}"
|
113
|
+
@connection.execute(sql).each do |row|
|
114
|
+
column_defaults[row['attname']] = row['adsrc']
|
115
|
+
end
|
110
116
|
|
111
117
|
with_search_path([schema_name]) do
|
112
118
|
# select * from pg_table_def where tablename = 'bids' and schemaname = 'public';
|
@@ -137,6 +143,10 @@ module ActiverecordRedshift
|
|
137
143
|
if row['sortkey'] != "0"
|
138
144
|
sortkeys[row['sortkey'].to_i - 1] = column_name
|
139
145
|
end
|
146
|
+
unless column_defaults[column_name].blank?
|
147
|
+
column_info << "default #{column_defaults[column_name]}"
|
148
|
+
end
|
149
|
+
|
140
150
|
sql_columns << column_info.join(" ")
|
141
151
|
end
|
142
152
|
|