#NEWLINE# @ testing . requires . nullsordering #NEWLINE# def test_order_by_nulls( self ) : #NEWLINE# #INDENT# 'Exercises ORDER BY clause generation.\n\n        Tests simple, compound, aliased and DESC clauses.\n        ' #NEWLINE# users . insert ( ) . execute ( user_id = 1 ) #NEWLINE# users . insert ( ) . execute ( user_id = 2 , user_name = 'b' ) #NEWLINE# users . insert ( ) . execute ( user_id = 3 , user_name = 'a' ) #NEWLINE# def a_eq( executable , wanted ) : #NEWLINE# #INDENT# got = list ( executable . execute ( ) ) #NEWLINE# eq_ ( got , wanted ) #NEWLINE# #UNINDENT# for labels in ( False , True ) : #NEWLINE# #INDENT# a_eq ( users . select ( order_by = [ users . c . user_name . nullsfirst ( ) ] , use_labels = labels ) , [ ( 1 , None ) , ( 3 , 'a' ) , ( 2 , 'b' ) ] ) #NEWLINE# a_eq ( users . select ( order_by = [ users . c . user_name . nullslast ( ) ] , use_labels = labels ) , [ ( 3 , 'a' ) , ( 2 , 'b' ) , ( 1 , None ) ] ) #NEWLINE# a_eq ( users . select ( order_by = [ asc ( users . c . user_name ) . nullsfirst ( ) ] , use_labels = labels ) , [ ( 1 , None ) , ( 3 , 'a' ) , ( 2 , 'b' ) ] ) #NEWLINE# a_eq ( users . select ( order_by = [ asc ( users . c . user_name ) . nullslast ( ) ] , use_labels = labels ) , [ ( 3 , 'a' ) , ( 2 , 'b' ) , ( 1 , None ) ] ) #NEWLINE# a_eq ( users . select ( order_by = [ users . c . user_name . desc ( ) . nullsfirst ( ) ] , use_labels = labels ) , [ ( 1 , None ) , ( 2 , 'b' ) , ( 3 , 'a' ) ] ) #NEWLINE# a_eq ( users . select ( order_by = [ users . c . user_name . desc ( ) . nullslast ( ) ] , use_labels = labels ) , [ ( 2 , 'b' ) , ( 3 , 'a' ) , ( 1 , None ) ] ) #NEWLINE# a_eq ( users . select ( order_by = [ desc ( users . c . user_name ) . nullsfirst ( ) ] , use_labels = labels ) , [ ( 1 , None ) , ( 2 , 'b' ) , ( 3 , 'a' ) ] ) #NEWLINE# a_eq ( users . select ( order_by = [ desc ( users . c . user_name ) . nullslast ( ) ] , use_labels = labels ) , [ ( 2 , 'b' ) , ( 3 , 'a' ) , ( 1 , None ) ] ) #NEWLINE# a_eq ( users . select ( order_by = [ users . c . user_name . nullsfirst ( ) , users . c . user_id ] , use_labels = labels ) , [ ( 1 , None ) , ( 3 , 'a' ) , ( 2 , 'b' ) ] ) #NEWLINE# a_eq ( users . select ( order_by = [ users . c . user_name . nullslast ( ) , users . c . user_id ] , use_labels = labels ) , [ ( 3 , 'a' ) , ( 2 , 'b' ) , ( 1 , None ) ] )