Class: Pinspec::SchemaGraph
- Inherits:
-
Data
- Object
- Data
- Pinspec::SchemaGraph
- Defined in:
- lib/pinspec/types.rb
Instance Attribute Summary collapse
-
#fk_map ⇒ Object
readonly
Returns the value of attribute fk_map.
-
#foreign_keys ⇒ Object
readonly
Returns the value of attribute foreign_keys.
-
#skipped_statements ⇒ Object
readonly
Returns the value of attribute skipped_statements.
-
#tables ⇒ Object
readonly
Returns the value of attribute tables.
Instance Method Summary collapse
- #annotate_relevance(planned_tables) ⇒ Object
- #fk_for(table_name, column_name) ⇒ Object
- #foreign_keys_from(table_name) ⇒ Object
- #table(name) ⇒ Object
- #table_names ⇒ Object
- #unknown_columns ⇒ Object
Instance Attribute Details
#fk_map ⇒ Object (readonly)
Returns the value of attribute fk_map
468 469 470 |
# File 'lib/pinspec/types.rb', line 468 def fk_map @fk_map end |
#foreign_keys ⇒ Object (readonly)
Returns the value of attribute foreign_keys
468 469 470 |
# File 'lib/pinspec/types.rb', line 468 def foreign_keys @foreign_keys end |
#skipped_statements ⇒ Object (readonly)
Returns the value of attribute skipped_statements
468 469 470 |
# File 'lib/pinspec/types.rb', line 468 def skipped_statements @skipped_statements end |
#tables ⇒ Object (readonly)
Returns the value of attribute tables
468 469 470 |
# File 'lib/pinspec/types.rb', line 468 def tables @tables end |
Instance Method Details
#annotate_relevance(planned_tables) ⇒ Object
489 490 491 492 493 494 495 |
# File 'lib/pinspec/types.rb', line 489 def annotate_relevance(planned_tables) wanted = Array(planned_tables).map(&:to_s) with(skipped_statements: skipped_statements.map do |statement| statement.with(relevant: statement.tables_touched.any? { |t| wanted.include?(t) }) end) end |
#fk_for(table_name, column_name) ⇒ Object
477 478 479 |
# File 'lib/pinspec/types.rb', line 477 def fk_for(table_name, column_name) foreign_keys.find { |fk| fk.from_table == table_name.to_s && fk.column == column_name.to_s } end |
#foreign_keys_from(table_name) ⇒ Object
481 482 483 |
# File 'lib/pinspec/types.rb', line 481 def foreign_keys_from(table_name) foreign_keys.select { |fk| fk.from_table == table_name.to_s } end |
#table(name) ⇒ Object
469 470 471 |
# File 'lib/pinspec/types.rb', line 469 def table(name) tables.find { |t| t.name == name.to_s } end |
#table_names ⇒ Object
473 474 475 |
# File 'lib/pinspec/types.rb', line 473 def table_names tables.map(&:name) end |
#unknown_columns ⇒ Object
485 486 487 |
# File 'lib/pinspec/types.rb', line 485 def unknown_columns tables.flat_map { |t| t.columns.select(&:unknown_type?).map { |c| [t.name, c] } } end |