SQLite return wrong column name when using query as table (transplanted from 5c38493067b4de52ece25abaf4353bc48f312299)