def _constraint_names(self, model, column_names=None, unique=None,<EOL>primary_key=None, index=None, foreign_key=None,<EOL>check=None):
column_names = list(column_names) if column_names else None<EOL>with self.connection.cursor() as cursor:<EOL><INDENT>constraints = get_constraints(cursor, model._meta.db_table)<EOL><DEDENT>result = []<EOL>for name, infodict in constraints.items():<EOL><INDENT>if column_names is None or column_names == infodict['<STR_LIT>']:<EOL><INDENT>if unique is not None and infodict['<STR_LIT>'] != unique:<EOL><INDENT>continue<EOL><DEDENT>if primary_key is not None and infodict['<STR_LIT:primary_key>'] != primary_key:<EOL><INDENT>continue<EOL><DEDENT>if index is not None and infodict['<STR_LIT:index>'] != index:<EOL><INDENT>continue<EOL><DEDENT>if check is not None and infodict['<STR_LIT>'] != check:<EOL><INDENT>continue<EOL><DEDENT>if foreign_key is not None and not infodict['<STR_LIT>']:<EOL><INDENT>continue<EOL><DEDENT>result.append(name)<EOL><DEDENT><DEDENT>return result<EOL>
Returns all constraint names matching the columns and conditions