I encountered some problems while trying to use this library with apollo-server setup using PostgreSQL as database and knex. My setup doesn't use objection ORM, it just calls knex queries straight from the resolver.
I forked the library and added posgres driver to isolate the issue from my setup. I created a new table, cities, since my initial problem was concerning a calculated column, which shows distance between coordinates in the database compared to coordinates in the query.
Most of the added code is here. The file contains detailed comments on the problem. I also added notes to the readme on how to run dockerized posgres to test this on. By the way, this can not be tested on sqlite since it doesn't have the necessary math functions to calculate distances.
I encountered two problems.
.groupBy('id') is needed when selecting the columns using .select(). Even though the exact same query is generated with .select(['*']) and omitting the select altogether. When driving the sqlite driver, this problem doesn't occur. See implementation2 in the file linked before.
- When adding the custom column to the select array, it works fine when using only
first pagination parameter. The column appears in the results and results can be sorted based on the calculated column. Using anything else than first breaks the query. See implementation3.
Any idea what might be causing this?
If you would like to include the test cases in the repo, I can clean them up and do a PR. There are no tests tho, didn't have time to setup postgres tests. I also added some general notes on the readme, feel free to copy them if you feel so :)
I encountered some problems while trying to use this library with apollo-server setup using PostgreSQL as database and knex. My setup doesn't use objection ORM, it just calls knex queries straight from the resolver.
I forked the library and added posgres driver to isolate the issue from my setup. I created a new table,
cities, since my initial problem was concerning a calculated column, which shows distance between coordinates in the database compared to coordinates in the query.Most of the added code is here. The file contains detailed comments on the problem. I also added notes to the readme on how to run dockerized posgres to test this on. By the way, this can not be tested on sqlite since it doesn't have the necessary math functions to calculate distances.
I encountered two problems.
.groupBy('id')is needed when selecting the columns using.select(). Even though the exact same query is generated with.select(['*'])and omitting the select altogether. When driving the sqlite driver, this problem doesn't occur. Seeimplementation2in the file linked before.firstpagination parameter. The column appears in the results and results can be sorted based on the calculated column. Using anything else thanfirstbreaks the query. Seeimplementation3.Any idea what might be causing this?
If you would like to include the test cases in the repo, I can clean them up and do a PR. There are no tests tho, didn't have time to setup postgres tests. I also added some general notes on the readme, feel free to copy them if you feel so :)