提交 08df10a9 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #30970 from rohitpaulk/fix-sqlite-3-index-order-dump

Save index order :desc to schema.rb (sqlite). Fixes #30902
* Fixed a bug where column orders for an index weren't written to
db/schema.rb when using the sqlite adapter.
Fixes #30902.
*Paul Kuruvilla*
* Remove deprecated method `#sanitize_conditions`.
*Rafael Mendonça França*
......
......@@ -23,12 +23,22 @@ def indexes(table_name)
col["name"]
end
# Add info on sort order for columns (only desc order is explicitly specified, asc is
# the default)
orders = {}
if index_sql # index_sql can be null in case of primary key indexes
index_sql.scan(/"(\w+)" DESC/).flatten.each { |order_column|
orders[order_column] = :desc
}
end
IndexDefinition.new(
table_name,
row["name"],
row["unique"] != 0,
columns,
where: where
where: where,
orders: orders
)
end
end
......
......@@ -186,7 +186,7 @@ def test_schema_dumps_index_columns_in_right_order
assert_equal 't.index ["firm_id", "type", "rating"], name: "company_index", length: { type: 10 }', index_definition
end
else
assert_equal 't.index ["firm_id", "type", "rating"], name: "company_index"', index_definition
assert_equal 't.index ["firm_id", "type", "rating"], name: "company_index", order: { rating: :desc }', index_definition
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册