lomba/schema_plus — pull request #114 by tovodeverett (2013-07-29 20:44:19+00:00)
Title: Fix creation of case insensitive indexes with non-caseable columns

* `SchemaPlus::ActiveRecord::ConnectionAdapters::PostgresqlAdapter#add_index`
had issues creating case insensitive indexes if there were non-caseable
(i.e. integer, numeric, etc.) columns that didn't end in `_id`.
* I added tests to `spec/schema_dumper_spec.rb` for all of the Rails-defined
non-caseable column types. I added columns for each of these types to
the posts table and then defined the tests for each of these columns
using iteration.
* The code fix took more work than I initially thought. It took me a while
to locate the `#columns` method. Although the method signature in 3.2.14
lists a second optional parameter of `name`, it doesn't appear to do
anything with that parameter and the parameter was removed in 4.0.0. So
I filter through the complete list to extract the caseable columns (I
considered other approaches, but this one balanced out line lengths best
without refactoring the code massively) and then use that in the test.
Since this work is only required for case insensitive indexes, I hoisted
the case insensitive test outside of the `quoted_column_names` enumeration.
* Note that this will produce a change in behavior if users have columns that
end in `_id` and that are of type `:string` or `:text` - previously these
columns would have been case sensitive in the index, and now they will be
case insensitive.