Store associations in query