If I have a database called students and inside that database I have a table also called students then
private def view_definition(name)
execute("SHOW CREATE VIEW #{quote_table_name(name)}")
.first[1]
.sub(/\A.*#{quote_table_name(name)} AS /i, '')
.gsub(/#{quote_table_name(@connectable.connection.current_database)}\./, '')
end
will replace the name of the table, leading to errors such as Mysql2::Error: Column 'id' in field list is ambiguous.
It should replace only the very first match, not all of them.