Fixed query implementation to work with null-padding, type and length coercion.