Class: PgGraph::Type::Table
- Inherits:
-
SchemaObject
- Object
- HashTree::Set
- Node
- SchemaObject
- PgGraph::Type::Table
- Includes:
- TableObject
- Defined in:
- lib/pg_graph/type/type.rb
Overview
A table. Note that a table doesn’t have child objects. Instead it has a type property that has the record type as child
Instance Attribute Summary collapse
-
#depending_materialized_views ⇒ Object
readonly
This is a hack since graph_db doesn’t model views.
-
#depending_tables ⇒ Object
readonly
Array of tables in the transitive closure of table dependencies.
-
#path ⇒ Object
readonly
Qualified name of table (ie. schema.table).
-
#type ⇒ Object
(also: #table_type)
readonly
Table type.
Instance Method Summary collapse
-
#initialize(schema, name, mm_table: false, nm_table: false, depending_materialized_views: []) ⇒ Table
constructor
A new instance of Table.
- #mm_table? ⇒ Boolean
- #nm_table? ⇒ Boolean
-
#root_table ⇒ Object
Recursive parent table if table is a derived table and otherwise nil.
-
#sub_table? ⇒ Boolean
True if table is a derived table.
-
#super_table ⇒ Object
Parent table if this table is a derived table and otherwise nil.
-
#super_table? ⇒ Boolean
True if table is a parent table.
Methods included from TableObject
Methods inherited from SchemaObject
Methods inherited from Node
#dump, #guid, #identifier, #inspect, #inspect_inner, #schema_identifier
Constructor Details
#initialize(schema, name, mm_table: false, nm_table: false, depending_materialized_views: []) ⇒ Table
Returns a new instance of Table.
179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/pg_graph/type/type.rb', line 179 def initialize( schema, name, mm_table: false, nm_table: false, depending_materialized_views: []) PgGraph.inflector.plural?(name) or raise Error, "Table names should be plural: #{schema.name}.#{name}" super(schema, name) @path = "#{schema.name}.#{name}" @mm_table = mm_table || nm_table @nm_table = nm_table @depending_tables = [] @depending_materialized_views = depending_materialized_views end |
Instance Attribute Details
#depending_materialized_views ⇒ Object (readonly)
This is a hack since graph_db doesn’t model views. It is needed because PgGraph::Data needs to know which materialized views to refresh after data has been loaded
177 178 179 |
# File 'lib/pg_graph/type/type.rb', line 177 def depending_materialized_views @depending_materialized_views end |
#depending_tables ⇒ Object (readonly)
Array of tables in the transitive closure of table dependencies. It is initialized by Database#read_meta
172 173 174 |
# File 'lib/pg_graph/type/type.rb', line 172 def depending_tables @depending_tables end |
#path ⇒ Object (readonly)
Qualified name of table (ie. schema.table). FIXME: We already have Node#path???
147 148 149 |
# File 'lib/pg_graph/type/type.rb', line 147 def path @path end |
#type ⇒ Object Also known as: table_type
Table type. Initially nil. Initialized by RecordType.new
150 151 152 |
# File 'lib/pg_graph/type/type.rb', line 150 def type @type end |
Instance Method Details
#mm_table? ⇒ Boolean
167 |
# File 'lib/pg_graph/type/type.rb', line 167 def mm_table?() @mm_table end |
#nm_table? ⇒ Boolean
168 |
# File 'lib/pg_graph/type/type.rb', line 168 def nm_table?() @nm_table end |
#root_table ⇒ Object
Recursive parent table if table is a derived table and otherwise nil
162 |
# File 'lib/pg_graph/type/type.rb', line 162 def root_table = record_type.root_record&.table |
#sub_table? ⇒ Boolean
True if table is a derived table. TODO: Use sub_table etc.
156 |
# File 'lib/pg_graph/type/type.rb', line 156 def sub_table?() !super_table.nil? end |
#super_table ⇒ Object
Parent table if this table is a derived table and otherwise nil
159 |
# File 'lib/pg_graph/type/type.rb', line 159 def super_table = record_type.super_record&.table |
#super_table? ⇒ Boolean
True if table is a parent table. Initialized by #read
165 |
# File 'lib/pg_graph/type/type.rb', line 165 def super_table?() record_type.sub_record? end |