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