aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-10-25 11:44:08 -0400
committerGitHub <noreply@github.com>2017-10-25 11:44:08 -0400
commit08df10a95b4a72128ff5e5cee858c29c149e22a7 (patch)
treeda93471a499c79fd6beb234b88c1f0be3615ffa6 /activerecord/lib/active_record
parentdf4632fece02d5a780f6d71e688499cb7b4bfcf3 (diff)
parentab8c7a518eb9583dbc574ff68fd56bcccf383452 (diff)
downloadrails-08df10a95b4a72128ff5e5cee858c29c149e22a7.tar.gz
rails-08df10a95b4a72128ff5e5cee858c29c149e22a7.tar.bz2
rails-08df10a95b4a72128ff5e5cee858c29c149e22a7.zip
Merge pull request #30970 from rohitpaulk/fix-sqlite-3-index-order-dump
Save index order :desc to schema.rb (sqlite). Fixes #30902
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb
index f0d702136d..58e5138e02 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb
@@ -23,12 +23,22 @@ module ActiveRecord
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