Fix identifier quoting on Oracle/Postgres

This fixes issue #885
Oracle and Postgres (at least) don't like to have quoted alias when trying
to group by them. This fix gets around the issue by quoting only identifiers
that have a space/dot in them.
is this change intended?