diff --git a/lib/active_record/connection_adapters/sqlserver/schema_statements.rb b/lib/active_record/connection_adapters/sqlserver/schema_statements.rb index 87713cd5a..276a2f2ed 100644 --- a/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +++ b/lib/active_record/connection_adapters/sqlserver/schema_statements.rb @@ -388,7 +388,7 @@ def column_definitions(table_name) if view_exists results = sp_executesql %{ - SELECT c.COLUMN_NAME AS [name], c.COLUMN_DEFAULT AS [default] + SELECT LOWER(c.COLUMN_NAME) AS [name], c.COLUMN_DEFAULT AS [default] FROM #{database}.INFORMATION_SCHEMA.COLUMNS c WHERE c.TABLE_NAME = #{quote(view_tblnm)} }.squish, "SCHEMA", [] @@ -426,7 +426,7 @@ def column_definitions(table_name) ci[:default_function] = begin default = ci[:default_value] if default.nil? && view_exists - view_column = views_real_column_name(table_name, ci[:name]) + view_column = views_real_column_name(table_name, ci[:name]).downcase default = default_functions[view_column] if view_column.present? end case default