A pysqlite user reported a problem with COALESCE. I could find out that his test case worked ok with SQLite versions 3.6.12 through 3.6.20, but failed with 3.6.21 to 3.6.23.
I could narrow down his test case to this very simple one below. The combination of addition, named parameters and COALESCE causes problems. The first SQL produces the expected result, but if you swap the operands, NULL is produced. SQLite developers, ghaer...@ws124~/src/gh/pysqlite/build/lib.macosx-10.6-universal-2.6$ cat t.py from pysqlite2 import dbapi2 as sqlite3 print "SQLite", sqlite3.sqlite_version con = sqlite3.connect(":memory:") print con.execute('SELECT ? + coalesce(max((select 1)), ?)', (1, 0)).fetchone() print con.execute('SELECT coalesce(max((select 1)), ?) + ?', (0, 1)).fetchone() ghaer...@ws124~/src/gh/pysqlite/build/lib.macosx-10.6-universal-2.6$ python t.py SQLite 3.6.23.1 (2,) (None,) _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users