#NEWLINE# def test_regression_7314_7372( self ) : #NEWLINE# #INDENT# '\n        Regression tests for #7314 and #7372\n        ' #NEWLINE# rm = RevisionableModel . objects . create ( title = 'First Revision' , when = datetime . datetime ( 2008 , 9 , 28 , 10 , 30 , 0 ) ) #NEWLINE# self . assertEqual ( rm . pk , rm . base . pk ) #NEWLINE# rm2 = rm . new_revision ( ) #NEWLINE# rm2 . title = 'Second Revision' #NEWLINE# rm . when = datetime . datetime ( 2008 , 9 , 28 , 14 , 25 , 0 ) #NEWLINE# rm2 . save ( ) #NEWLINE# self . assertEqual ( rm2 . title , 'Second Revision' ) #NEWLINE# self . assertEqual ( rm2 . base . title , 'First Revision' ) #NEWLINE# self . assertNotEqual ( rm2 . pk , rm . pk ) #NEWLINE# self . assertEqual ( rm2 . base . pk , rm . pk ) #NEWLINE# qs = RevisionableModel . objects . extra ( where = [ ( '%(table)s.id IN (SELECT MAX(rev.id) FROM %(table)s rev GROUP BY rev.base_id)' % { #NEWLINE# #INDENT# 'table' : RevisionableModel . _meta . db_table , #NEWLINE# #UNINDENT# } ) ] ) #NEWLINE# self . assertQuerysetEqual ( qs , [ ( 'Second Revision' , 'First Revision' ) ] , transform = ( lambda r : ( r . title , r . base . title ) ) ) #NEWLINE# qs2 = RevisionableModel . objects . filter ( title__contains = 'Revision' ) #NEWLINE# self . assertQuerysetEqual ( qs , [ ( 'First Revision' , 'First Revision' ) , ( 'Second Revision' , 'First Revision' ) ] , transform = ( lambda r : ( r . title , r . base . title ) ) , ordered = False ) #NEWLINE# self . assertQuerysetEqual ( ( qs & qs2 ) , [ ( 'Second Revision' , 'First Revision' ) ] , transform = ( lambda r : ( r . title , r . base . title ) ) , ordered = False )