Hi,On Thu, Apr 23, 2015 at 8:07 PM, Andreas Tille <andreas@an3as.eu> wrote:Hi,
However, to save my idea to avoid
code duplication what about a helper returning a table
source text,
bibentry text
and use this helper in both functions that just return the bibentries.
I'm just afraid that we might change anything later and will forget to
change in both functions (been there to much times ;-)).
I was thinking we could modify generate_bibtex.py to:# create BibTeX filebf = open(self.bibtexfile, 'w')bibentry = "(SELECT DISTINCT source, package, rank FROM bibref) p "if self.all_ref == 1:query = "SELECT * FROM bibtex(bibentry)"else:bibentry += "INNER JOIN sources s ON s.source = p.source "query = "SELECT * FROM bibtex(bibentry)"cur.execute(query)for row in cur.fetchall():print >>bf, row[0]bf.close()Thus, upgrade_bibtex.sql can take a parameter:CREATE OR REPLACE FUNCTION bibtex (text)RETURNS SETOF TEXT LANGUAGE SQLAS $$SELECT DISTINCTCASE..............................FROM $1LEFT OUTER JOIN bibref bibkey ......................