diff --git a/cli/worblehat.py b/cli/worblehat.py index 45ea697..0dc1e2b 100755 --- a/cli/worblehat.py +++ b/cli/worblehat.py @@ -272,7 +272,11 @@ def search_book(connection, search_strings, search_description=False): else: for i in range(5): result_list.append(s) - c.execute('SELECT * FROM book LEFT JOIN bookperson ON book.isbn=bookperson.book LEFT JOIN person ON person.id=bookperson.person WHERE ' + ' OR '.join(where_clauses), map(lambda s:'%' + s + '%',result_list)) + c.execute('SELECT isbn,book.id AS id,title,category, \ + array_to_string(array_agg(person.lastname || \' (\' || person.id || \')\', \', \') AS persons \ + FROM book LEFT JOIN bookperson ON book.isbn=bookperson.book \ + LEFT JOIN person ON person.id=bookperson.person \ + WHERE ' + ' OR '.join(where_clauses), map(lambda s:'%' + s + '%',result_list)) for i in xrange(c.rowcount): book = fetchone_dict(c) print book['isbn'], book['title'], book['person']