diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb | 11 |
1 files changed, 9 insertions, 2 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..3ab9dee370 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb @@ -19,8 +19,14 @@ module ActiveRecord /\sWHERE\s+(?<where>.+)$/i =~ index_sql - columns = exec_query("PRAGMA index_info(#{quote(row['name'])})", "SCHEMA").map do |col| - col["name"] + columns = [] + orders = {} + exec_query("PRAGMA index_xinfo(#{quote(row['name'])})", "SCHEMA").each do |col| + # xinfo also lists non-key columns, let's filter those out + next if col["key"] == 0 + + columns << col["name"] + orders[col["name"]] = :desc if col["desc"] == 1 end IndexDefinition.new( @@ -28,6 +34,7 @@ module ActiveRecord row["name"], row["unique"] != 0, columns, + orders: orders, where: where ) end |