Sha256: 4774e93c8fff0f0cf78a8479b9caaea4993a0aad57073afe4153ec2c4df431d7

Contents?: true

Size: 552 Bytes

Versions: 5

Compression:

Stored size: 552 Bytes

Contents

module SchemaPlus::Views
  module ActiveRecord
    module ConnectionAdapters
      module Sqlite3Adapter

        def views(name = nil)
          execute("SELECT name FROM sqlite_master WHERE type='view'", name).collect{|row| row["name"]}
        end

        def view_definition(view_name, name = nil)
          sql = execute("SELECT sql FROM sqlite_master WHERE type='view' AND name=#{quote(view_name)}", name).collect{|row| row["sql"]}.first
          sql.sub(/^CREATE VIEW \S* AS\s+/im, '') unless sql.nil?
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
schema_plus_views-0.2.3 lib/schema_plus/views/active_record/connection_adapters/sqlite3_adapter.rb
schema_plus_views-0.2.2 lib/schema_plus/views/active_record/connection_adapters/sqlite3_adapter.rb
schema_plus_views-0.2.1 lib/schema_plus/views/active_record/connection_adapters/sqlite3_adapter.rb
schema_plus_views-0.2.0 lib/schema_plus/views/active_record/connection_adapters/sqlite3_adapter.rb
schema_plus_views-0.1.0 lib/schema_plus/views/active_record/connection_adapters/sqlite3_adapter.rb