activerecord-redshift-adapter 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
 
@@ -1,4 +1,4 @@
1
1
  module ActiverecordRedshiftAdapter
2
2
  # the current version of this gem
3
- VERSION = "0.9.5"
3
+ VERSION = "0.9.6"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-redshift-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: