summaryrefslogtreecommitdiff
path: root/config/initializers/postgresql_limit_fix.rb
diff options
context:
space:
mode:
authorAndrey Kumanyaev <me@zzet.org>2012-10-10 03:41:14 +0400
committerAndrey Kumanyaev <me@zzet.org>2012-10-10 13:17:48 +0400
commit75e6eb59ecd21735c87eb53eb68d510760580b3f (patch)
treec10cafa9f764d4915ba5ef42c16a6088380c286c /config/initializers/postgresql_limit_fix.rb
parent4eb7d82ae7b085049a889b8f4e7d421f05b39d07 (diff)
downloadgitlab-ce-75e6eb59ecd21735c87eb53eb68d510760580b3f.tar.gz
patch rails to ignore text limit
Diffstat (limited to 'config/initializers/postgresql_limit_fix.rb')
-rw-r--r--config/initializers/postgresql_limit_fix.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/config/initializers/postgresql_limit_fix.rb b/config/initializers/postgresql_limit_fix.rb
new file mode 100644
index 00000000000..0cb3aaf4d24
--- /dev/null
+++ b/config/initializers/postgresql_limit_fix.rb
@@ -0,0 +1,26 @@
+if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
+ class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
+ class TableDefinition
+ def text(*args)
+ options = args.extract_options!
+ options.delete(:limit)
+ column_names = args
+ type = :text
+ column_names.each { |name| column(name, type, options) }
+ end
+ end
+
+ def add_column_with_limit_filter(table_name, column_name, type, options = {})
+ options.delete(:limit) if type == :text
+ add_column_without_limit_filter(table_name, column_name, type, options)
+ end
+
+ def change_column_with_limit_filter(table_name, column_name, type, options = {})
+ options.delete(:limit) if type == :text
+ change_column_without_limit_filter(table_name, column_name, type, options)
+ end
+
+ alias_method_chain :add_column, :limit_filter
+ alias_method_chain :change_column, :limit_filter
+ end
+end