All pastes #185363 Raw Edit

Anonymous

public text v1 · immutable
#185363 ·published 2006-09-28 21:37 UTC
rendered paste body
query = session.query(Movie)       
clauses = []
if moviesearch.finnishTitle is not None:
    clauses.append(func.lower(self.movie_table.c.finnish_name) ==

                        moviesearch.finnishTitle.lower())
if moviesearch.yearStart is not None:
    clauses.append(self.movie_table.c.year >= moviesearch.yearStart)

if moviesearch.yearEnd is not None:
    clauses.append(self.movie_table.c.year <= moviesearch.yearEnd)   

                       

if moviesearch.imdbID is not None:
    clauses.append(or_(func.lower(self.movie_table.c.url).like('%' + moviesearch.imdbID + '%'),

                             func.lower(self.movie_table.c.imdb_url).like('%' + moviesearch.imdbID + '%')))
                             
return query.select(and_(*clauses))