Fix #2532: Allow AR behaviors to attach other behaviors to Query

This one attmpts to fix #2532: "Allow AR behaviors to attach other behaviors to Query"

Unit test is attached.

Migrated from #3898