fix sql in trip model to work with postgres