instance method
fetch_check_constraints
Ruby on Rails edge
Since edge Private — implementation detail, not part of the public APISignature
fetch_check_constraints(tables)
No documentation comment.
Parameters
-
tablesreq
Source
# File activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb, line 797
def fetch_check_constraints(tables)
raise NotImplementedError unless supports_check_constraints?
fetch_by_schema(tables) do |schema, group|
names = quoted_table_names(group)
sql = +<<~SQL
SELECT tc.table_name AS 'table',
cc.constraint_name AS 'name',
cc.check_clause AS 'expression'
FROM information_schema.check_constraints cc
JOIN information_schema.table_constraints tc
USING (constraint_schema, constraint_name)
WHERE tc.table_schema = #{schema}
AND tc.table_name IN (#{names})
AND cc.constraint_schema = #{schema}
SQL
sql << " AND cc.table_name IN (#{names})" if mariadb?
by_name = query_all(sql).group_by { |row| row["table"] }
group.index_with { |table| build_check_constraints(table, rows_for(by_name, table)) }
end
end
Defined in activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb line 797
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter