#NEWLINE# def test_values( self ) : #NEWLINE# #INDENT# identity = ( lambda x : x ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . values ( 'headline' ) , [ { #NEWLINE# #INDENT# 'headline' : 'Article 5' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : 'Article 6' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : 'Article 4' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : 'Article 2' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : 'Article 3' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : 'Article 7' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : 'Article 1' , #NEWLINE# #UNINDENT# } ] , transform = identity ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . filter ( pub_date__exact = datetime ( 2005 , 7 , 27 ) ) . values ( 'id' ) , [ { #NEWLINE# #INDENT# 'id' : self . a2 . id , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a3 . id , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a7 . id , #NEWLINE# #UNINDENT# } ] , transform = identity ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . values ( 'id' , 'headline' ) , [ { #NEWLINE# #INDENT# 'id' : self . a5 . id , #NEWLINE# 'headline' : 'Article 5' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a6 . id , #NEWLINE# 'headline' : 'Article 6' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a4 . id , #NEWLINE# 'headline' : 'Article 4' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a2 . id , #NEWLINE# 'headline' : 'Article 2' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a3 . id , #NEWLINE# 'headline' : 'Article 3' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a7 . id , #NEWLINE# 'headline' : 'Article 7' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a1 . id , #NEWLINE# 'headline' : 'Article 1' , #NEWLINE# #UNINDENT# } ] , transform = identity ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . values ( 'id' , 'headline' ) . iterator ( ) , [ { #NEWLINE# #INDENT# 'headline' : 'Article 5' , #NEWLINE# 'id' : self . a5 . id , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : 'Article 6' , #NEWLINE# 'id' : self . a6 . id , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : 'Article 4' , #NEWLINE# 'id' : self . a4 . id , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : 'Article 2' , #NEWLINE# 'id' : self . a2 . id , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : 'Article 3' , #NEWLINE# 'id' : self . a3 . id , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : 'Article 7' , #NEWLINE# 'id' : self . a7 . id , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : 'Article 1' , #NEWLINE# 'id' : self . a1 . id , #NEWLINE# #UNINDENT# } ] , transform = identity ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . extra ( select = { #NEWLINE# #INDENT# 'id_plus_one' : 'id + 1' , #NEWLINE# #UNINDENT# } ) . values ( 'id' , 'id_plus_one' ) , [ { #NEWLINE# #INDENT# 'id' : self . a5 . id , #NEWLINE# 'id_plus_one' : ( self . a5 . id + 1 ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a6 . id , #NEWLINE# 'id_plus_one' : ( self . a6 . id + 1 ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a4 . id , #NEWLINE# 'id_plus_one' : ( self . a4 . id + 1 ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a2 . id , #NEWLINE# 'id_plus_one' : ( self . a2 . id + 1 ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a3 . id , #NEWLINE# 'id_plus_one' : ( self . a3 . id + 1 ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a7 . id , #NEWLINE# 'id_plus_one' : ( self . a7 . id + 1 ) , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'id' : self . a1 . id , #NEWLINE# 'id_plus_one' : ( self . a1 . id + 1 ) , #NEWLINE# #UNINDENT# } ] , transform = identity ) #NEWLINE# data = { #NEWLINE# #INDENT# 'id_plus_one' : 'id+1' , #NEWLINE# 'id_plus_two' : 'id+2' , #NEWLINE# 'id_plus_three' : 'id+3' , #NEWLINE# 'id_plus_four' : 'id+4' , #NEWLINE# 'id_plus_five' : 'id+5' , #NEWLINE# 'id_plus_six' : 'id+6' , #NEWLINE# 'id_plus_seven' : 'id+7' , #NEWLINE# 'id_plus_eight' : 'id+8' , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertQuerysetEqual ( Article . objects . filter ( id = self . a1 . id ) . extra ( select = data ) . values ( * data . keys ( ) ) , [ { #NEWLINE# #INDENT# 'id_plus_one' : ( self . a1 . id + 1 ) , #NEWLINE# 'id_plus_two' : ( self . a1 . id + 2 ) , #NEWLINE# 'id_plus_three' : ( self . a1 . id + 3 ) , #NEWLINE# 'id_plus_four' : ( self . a1 . id + 4 ) , #NEWLINE# 'id_plus_five' : ( self . a1 . id + 5 ) , #NEWLINE# 'id_plus_six' : ( self . a1 . id + 6 ) , #NEWLINE# 'id_plus_seven' : ( self . a1 . id + 7 ) , #NEWLINE# 'id_plus_eight' : ( self . a1 . id + 8 ) , #NEWLINE# #UNINDENT# } ] , transform = identity ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . values ( 'headline' , 'author__name' ) , [ { #NEWLINE# #INDENT# 'headline' : self . a5 . headline , #NEWLINE# 'author__name' : self . au2 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : self . a6 . headline , #NEWLINE# 'author__name' : self . au2 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : self . a4 . headline , #NEWLINE# 'author__name' : self . au1 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : self . a2 . headline , #NEWLINE# 'author__name' : self . au1 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : self . a3 . headline , #NEWLINE# 'author__name' : self . au1 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : self . a7 . headline , #NEWLINE# 'author__name' : self . au2 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'headline' : self . a1 . headline , #NEWLINE# 'author__name' : self . au1 . name , #NEWLINE# #UNINDENT# } ] , transform = identity ) #NEWLINE# self . assertQuerysetEqual ( Author . objects . values ( 'name' , 'article__headline' ) . order_by ( 'name' , 'article__headline' ) , [ { #NEWLINE# #INDENT# 'name' : self . au1 . name , #NEWLINE# 'article__headline' : self . a1 . headline , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au1 . name , #NEWLINE# 'article__headline' : self . a2 . headline , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au1 . name , #NEWLINE# 'article__headline' : self . a3 . headline , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au1 . name , #NEWLINE# 'article__headline' : self . a4 . headline , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au2 . name , #NEWLINE# 'article__headline' : self . a5 . headline , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au2 . name , #NEWLINE# 'article__headline' : self . a6 . headline , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au2 . name , #NEWLINE# 'article__headline' : self . a7 . headline , #NEWLINE# #UNINDENT# } ] , transform = identity ) #NEWLINE# self . assertQuerysetEqual ( Author . objects . values ( 'name' , 'article__headline' , 'article__tag__name' ) . order_by ( 'name' , 'article__headline' , 'article__tag__name' ) , [ { #NEWLINE# #INDENT# 'name' : self . au1 . name , #NEWLINE# 'article__headline' : self . a1 . headline , #NEWLINE# 'article__tag__name' : self . t1 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au1 . name , #NEWLINE# 'article__headline' : self . a2 . headline , #NEWLINE# 'article__tag__name' : self . t1 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au1 . name , #NEWLINE# 'article__headline' : self . a3 . headline , #NEWLINE# 'article__tag__name' : self . t1 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au1 . name , #NEWLINE# 'article__headline' : self . a3 . headline , #NEWLINE# 'article__tag__name' : self . t2 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au1 . name , #NEWLINE# 'article__headline' : self . a4 . headline , #NEWLINE# 'article__tag__name' : self . t2 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au2 . name , #NEWLINE# 'article__headline' : self . a5 . headline , #NEWLINE# 'article__tag__name' : self . t2 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au2 . name , #NEWLINE# 'article__headline' : self . a5 . headline , #NEWLINE# 'article__tag__name' : self . t3 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au2 . name , #NEWLINE# 'article__headline' : self . a6 . headline , #NEWLINE# 'article__tag__name' : self . t3 . name , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : self . au2 . name , #NEWLINE# 'article__headline' : self . a7 . headline , #NEWLINE# 'article__tag__name' : self . t3 . name , #NEWLINE# #UNINDENT# } ] , transform = identity ) #NEWLINE# self . assertRaises ( FieldError , Article . objects . extra ( select = { #NEWLINE# #INDENT# 'id_plus_one' : 'id + 1' , #NEWLINE# #UNINDENT# } ) . values , 'id' , 'id_plus_two' ) #NEWLINE# self . assertQuerysetEqual ( Article . objects . filter ( id = self . a5 . id ) . values ( ) , [ { #NEWLINE# #INDENT# 'id' : self . a5 . id , #NEWLINE# 'author_id' : self . au2 . id , #NEWLINE# 'headline' : 'Article 5' , #NEWLINE# 'pub_date' : datetime ( 2005 , 8 , 1 , 9 , 0 ) , #NEWLINE# #UNINDENT# } ] , transform = identity )