#NEWLINE# def test_values_with_extra( self ) : #NEWLINE# #INDENT# '\n        Regression test for #10256... If there is a values() clause, Extra\n        columns are only returned if they are explicitly mentioned.\n        ' #NEWLINE# obj = TestObject ( first = 'first' , second = 'second' , third = 'third' ) #NEWLINE# obj . save ( ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values ( ) ) , [ { #NEWLINE# #INDENT# 'bar' : 'second' , #NEWLINE# 'third' : 'third' , #NEWLINE# 'second' : 'second' , #NEWLINE# 'whiz' : 'third' , #NEWLINE# 'foo' : 'first' , #NEWLINE# 'id' : obj . pk , #NEWLINE# 'first' : 'first' , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . values ( ) . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) ) , [ { #NEWLINE# #INDENT# 'bar' : 'second' , #NEWLINE# 'third' : 'third' , #NEWLINE# 'second' : 'second' , #NEWLINE# 'whiz' : 'third' , #NEWLINE# 'foo' : 'first' , #NEWLINE# 'id' : obj . pk , #NEWLINE# 'first' : 'first' , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values ( 'first' , 'second' ) ) , [ { #NEWLINE# #INDENT# 'second' : 'second' , #NEWLINE# 'first' : 'first' , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . values ( 'first' , 'second' ) . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) ) , [ { #NEWLINE# #INDENT# 'second' : 'second' , #NEWLINE# 'first' : 'first' , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values ( 'first' , 'second' , 'foo' ) ) , [ { #NEWLINE# #INDENT# 'second' : 'second' , #NEWLINE# 'foo' : 'first' , #NEWLINE# 'first' : 'first' , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values ( 'foo' , 'whiz' ) ) , [ { #NEWLINE# #INDENT# 'foo' : 'first' , #NEWLINE# 'whiz' : 'third' , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values_list ( ) ) , [ ( 'first' , 'second' , 'third' , obj . pk , 'first' , 'second' , 'third' ) ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . values_list ( ) . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) ) , [ ( 'first' , 'second' , 'third' , obj . pk , 'first' , 'second' , 'third' ) ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values_list ( 'first' , 'second' ) ) , [ ( 'first' , 'second' ) ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . values_list ( 'first' , 'second' ) . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) ) , [ ( 'first' , 'second' ) ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values_list ( 'second' , flat = True ) ) , [ 'second' ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values_list ( 'first' , 'second' , 'whiz' ) ) , [ ( 'first' , 'second' , 'third' ) ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values_list ( 'foo' , 'whiz' ) ) , [ ( 'first' , 'third' ) ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values_list ( 'whiz' , flat = True ) ) , [ 'third' ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values_list ( 'whiz' , 'foo' ) ) , [ ( 'third' , 'first' ) ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values_list ( 'first' , 'id' ) ) , [ ( 'first' , obj . pk ) ] ) #NEWLINE# self . assertEqual ( list ( TestObject . objects . extra ( select = OrderedDict ( ( ( 'foo' , 'first' ) , ( 'bar' , 'second' ) , ( 'whiz' , 'third' ) ) ) ) . values_list ( 'whiz' , 'first' , 'bar' , 'id' ) ) , [ ( 'third' , 'first' , 'second' , obj . pk ) ] )