It seems that SQLite is trying hard to resolve the expressions to column names in the RETURNING clause. 't' is actually a string literal, whereas "t" is a quoted identifier that sometimes gets interpreted as a string literal, and I suspect you want only t without any quotes. Please note that column labels not set by an AS clause are generated by SQLite and are subject to change without notice.