class Scenic::View
The in-memory representation of a view definition.
**This object is used internally by adapters and the schema dumper and is not intended to be used by application code. It is documented here for use by adapter gems.**
@api extension
Attributes
definition[R]
The SQL schema for the query that defines the view @return [String]
@example
"SELECT name, email FROM users UNION SELECT name, email FROM contacts"
materialized[R]
True if the view is materialized @return [Boolean]
name[R]
The name of the view @return [String]
Public Class Methods
new(name:, definition:, materialized:)
click to toggle source
Returns a new instance of View
.
@param name [String] The name of the view. @param definition [String] The SQL for the query that defines the view. @param materialized [Boolean] ‘true` if the view is materialized.
# File lib/scenic/view.rb, line 30 def initialize(name:, definition:, materialized:) @name = name @definition = definition @materialized = materialized end
Public Instance Methods
==(other)
click to toggle source
@api private
# File lib/scenic/view.rb, line 37 def ==(other) name == other.name && definition == other.definition && materialized == other.materialized end
escaped_definition()
click to toggle source
# File lib/scenic/view.rb, line 54 def escaped_definition definition.gsub("\\", "\\\\\\") end
to_schema()
click to toggle source
@api private
# File lib/scenic/view.rb, line 44 def to_schema materialized_option = materialized ? "materialized: true, " : "" <<-DEFINITION create_view #{UnaffixedName.for(name).inspect}, #{materialized_option}sql_definition: <<-\SQL #{escaped_definition.indent(2)} SQL DEFINITION end