patch rails to ignore text limit

3-1-stable
Andrey Kumanyaev 2012-10-10 03:41:14 +04:00
parent 4eb7d82ae7
commit 75e6eb59ec
1 changed files with 26 additions and 0 deletions

View File

@ -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