Sha256: 3f3f21b341c3f5c9b5c34d71f5095d851bc1f79de781a0acec74d236781edea2
Contents?: true
Size: 665 Bytes
Versions: 5
Compression:
Stored size: 665 Bytes
Contents
module SchemaPlus::Indexes module Middleware module Schema module Sqlite3 module Indexes def after(env) indexes = Hash[env.index_definitions.map{ |d| [d.name, d] }] env.connection.exec_query("SELECT name, sql FROM sqlite_master WHERE type = 'index'").map do |row| if (desc_columns = row['sql'].scan(/['"`]?(\w+)['"`]? DESC\b/).flatten).any? index = indexes[row['name']] index.orders = Hash[index.columns.map {|column| [column, desc_columns.include?(column) ? :desc : :asc]}] end end end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems