Class: DatabaseDocumenter::DatabaseComment::MysqlDatabaseComment
- Inherits:
-
BaseDatabaseComment
- Object
- BaseDatabaseComment
- DatabaseDocumenter::DatabaseComment::MysqlDatabaseComment
- Defined in:
- lib/database_documenter/database_comment/mysql_database_comment.rb
Class Method Summary collapse
Methods inherited from BaseDatabaseComment
Class Method Details
.read_columns_comment(table_name) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/database_documenter/database_comment/mysql_database_comment.rb', line 3 def self.read_columns_comment(table_name) select_comment = <<-SQL SELECT `column_name`, `column_comment` FROM `information_schema`.`COLUMNS` WHERE `table_name` = '#{table_name}' AND `table_schema` = '#{database_name}' AND `column_comment` != ''; SQL ActiveRecord::Base.connection.execute(select_comment).to_h end |
.read_table_comment(table_name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/database_documenter/database_comment/mysql_database_comment.rb', line 15 def self.read_table_comment(table_name) select_comment = <<-SQL SELECT `TABLE_COMMENT` FROM `information_schema`.`TABLES` WHERE `TABLE_NAME` = '#{table_name}' AND `table_schema` = '#{database_name}'; SQL ActiveRecord::Base.connection.execute(select_comment).to_a.try('[]', 0).try('[]', 0) end |