Skip to content

Poor support of lowercase_schema_reflection  #641

@one-more-alex

Description

@one-more-alex

I started use of adapter and from first days enabled
lowercase_schema_reflection = true

But I faced with a bug in primary keys and proposed fix ##639

After several days of development I mentioned indexes case became uppercase again in schema.

I think mistakes are here:

        def indexes(table_name, name = nil)
          data = select("EXEC sp_helpindex #{quote(table_name)}", name) rescue []
          data.reduce([]) do |indexes, index|
            index = index.with_indifferent_access
            if index[:index_description] =~ /primary key/
              indexes
            else
              name    = index[:index_name]
              unique  = index[:index_description] =~ /unique/
              where   = select_value("SELECT [filter_definition] FROM sys.indexes WHERE name = #{quote(name)}")
              columns = index[:index_keys].split(',').map do |column|
                column.strip!
                column.gsub! '(-)', '' if column.ends_with?('(-)')
                column
              end
              indexes << IndexDefinition.new(table_name, name, unique, columns, nil, nil, where)
            end
          end
        end

Variables "name" and "column" should respect lowercase_schema_reflection. But they did not.

What I think, it worth to note in documentation, that lowercase_schema_reflection is rather experimental.
Finally I turned off lowercase_schema_reflection in my code...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions