fix for postgresql when using an alias.

Before applying see here:

https://code.google.com/p/web2py/issues/detail?id=1593