#NEWLINE# def test_join_switching( self ) : #NEWLINE# #INDENT# class Artist ( TestModel ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# class Track ( TestModel ) : #NEWLINE# #INDENT# artist = ForeignKeyField ( Artist ) #NEWLINE# #UNINDENT# class Release ( TestModel ) : #NEWLINE# #INDENT# artist = ForeignKeyField ( Artist ) #NEWLINE# #UNINDENT# class ReleaseTrack ( TestModel ) : #NEWLINE# #INDENT# track = ForeignKeyField ( Track ) #NEWLINE# release = ForeignKeyField ( Release ) #NEWLINE# #UNINDENT# class Genre ( TestModel ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# class TrackGenre ( TestModel ) : #NEWLINE# #INDENT# genre = ForeignKeyField ( Genre ) #NEWLINE# track = ForeignKeyField ( Track ) #NEWLINE# #UNINDENT# multiple_first = Track . select ( ) . join ( ReleaseTrack ) . join ( Release ) . switch ( Track ) . join ( Artist ) . switch ( Track ) . join ( TrackGenre ) . join ( Genre ) #NEWLINE# self . assertSelect ( multiple_first , '"track"."id", "track"."artist_id"' , [ ] ) #NEWLINE# self . assertJoins ( multiple_first , [ 'INNER JOIN "artist" AS artist ON ("track"."artist_id" = "artist"."id")' , 'INNER JOIN "genre" AS genre ON ("trackgenre"."genre_id" = "genre"."id")' , 'INNER JOIN "release" AS release ON ("releasetrack"."release_id" = "release"."id")' , 'INNER JOIN "releasetrack" AS releasetrack ON ("track"."id" = "releasetrack"."track_id")' , 'INNER JOIN "trackgenre" AS trackgenre ON ("track"."id" = "trackgenre"."track_id")' ] ) #NEWLINE# single_first = Track . select ( ) . join ( Artist ) . switch ( Track ) . join ( ReleaseTrack ) . join ( Release ) . switch ( Track ) . join ( TrackGenre ) . join ( Genre ) #NEWLINE# self . assertSelect ( single_first , '"track"."id", "track"."artist_id"' , [ ] ) #NEWLINE# self . assertJoins ( single_first , [ 'INNER JOIN "artist" AS artist ON ("track"."artist_id" = "artist"."id")' , 'INNER JOIN "genre" AS genre ON ("trackgenre"."genre_id" = "genre"."id")' , 'INNER JOIN "release" AS release ON ("releasetrack"."release_id" = "release"."id")' , 'INNER JOIN "releasetrack" AS releasetrack ON ("track"."id" = "releasetrack"."track_id")' , 'INNER JOIN "trackgenre" AS trackgenre ON ("track"."id" = "trackgenre"."track_id")' ] )