BUG: correctly lookup global constants in query/eval

closes #7178