loopbackio/loopback-connector-postgresql

Complex order statement fails

JuergenSimon opened this issue · 5 comments

#355 Steps to reproduce

We have a table that has fields weight (float) and voterId (integer, foreign key). We would like to sort the results of a query in the following way:

filter.order=["(weight/GREATEST(ABS(weight), 1)) DESC", "voterId ASC", "ABS(weight) DESC"]

Current Behavior

The query breaks with the following error:

error: column "(weight/greatest(abs(weight)" does not exist
    at Connection.parseE (.../node_modules/pg/lib/connection.js:581:48)
    at Connection.parseMessage (.../node_modules/pg/lib/connection.js:380:19)
    at Socket.<anonymous> (.../node_modules/pg/lib/connection.js:116:22)

Expected Behavior

The results are ordered as according to the statement that should be generated.

Additional information

This issue cropped up in 5.x versions of the connector. Perhaps it has something to do with the upgrade of pg?

ADDENDUM: Downgrading to 3.8.3 fixed the problem. 3.9.x exhibited it as well.

I would like to escalate this a little. The reason is, that I'm in a bind now. My old (high sierra) iMac died last week. It seems on Catalina, the 3.8.3 connector is no longer working at all (connection timeouts). This means I can only connect using the 5.0.1 connector, which exposes the bug described in this ticket.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale commented

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

I can report that this error was fixed but only when also using the latest version of loopback-connector.