#NEWLINE# def test_returning( self ) : #NEWLINE# #INDENT# iq = User . insert ( username = 'huey' ) #NEWLINE# test_db . returning_clause = False #NEWLINE# self . assertRaises ( ValueError , ( lambda : iq . returning ( User . id ) ) ) #NEWLINE# test_db . returning_clause = True #NEWLINE# iq_returning = iq . returning ( User . id ) #NEWLINE# self . assertFalse ( ( id ( iq_returning ) == id ( iq ) ) ) #NEWLINE# self . assertIsNone ( iq . _returning ) #NEWLINE# ( sql , params ) = normal_compiler . generate_insert ( iq_returning ) #NEWLINE# self . assertEqual ( sql , 'INSERT INTO "users" ("username") VALUES (?) RETURNING "users"."id"' ) #NEWLINE# self . assertEqual ( params , [ 'huey' ] ) #NEWLINE# iq2 = iq_returning . returning ( User , SQL ( '1' ) ) #NEWLINE# ( sql , params ) = normal_compiler . generate_insert ( iq2 ) #NEWLINE# self . assertEqual ( sql , 'INSERT INTO "users" ("username") VALUES (?) RETURNING "users"."id", "users"."username", 1' ) #NEWLINE# self . assertEqual ( params , [ 'huey' ] ) #NEWLINE# iq_no_return = iq2 . returning ( None ) #NEWLINE# ( sql , _ ) = normal_compiler . generate_insert ( iq_no_return ) #NEWLINE# self . assertFalse ( ( 'RETURNING' in self ) )