#NEWLINE# def test_sub_select( self ) : #NEWLINE# #INDENT# builder = self . get_builder ( ) #NEWLINE# marker = builder . get_grammar ( ) . get_marker ( ) #NEWLINE# expected_sql = ( 'SELECT "foo", "bar", (SELECT "baz" FROM "two" WHERE "subkey" = %s) AS "sub" FROM "one" WHERE "key" = %s' % ( marker , marker ) ) #NEWLINE# expected_bindings = [ 'subval' , 'val' ] #NEWLINE# builder . from_ ( 'one' ) . select ( 'foo' , 'bar' ) . where ( 'key' , '=' , 'val' ) #NEWLINE# builder . select_sub ( builder . new_query ( ) . from_ ( 'two' ) . select ( 'baz' ) . where ( 'subkey' , '=' , 'subval' ) , 'sub' ) #NEWLINE# self . assertEqual ( expected_sql , builder . to_sql ( ) ) #NEWLINE# self . assertEqual ( expected_bindings , builder . get_bindings ( ) )