vapor / fluent-postgres-driver

🐘 PostgreSQL driver for Fluent.
MIT License
146 stars 53 forks source link

Sort by multiple field keys fail #168

Open sprzenus opened 3 years ago

sprzenus commented 3 years ago

What I'm trying to do is to get sorted and paginated categories:

Category.query(on: req.db)
            .sort([Category.FieldKeys.nameEN, Category.FieldKeys.namePL])
            .paginate(PageRequest(page: options.page, per: options.itemsPerPage))

The logs I get from my database:

2020-10-17 09:45:49.272 UTC [2275] LOG:  execute <unnamed>: SELECT COUNT("categories"."id") AS "aggregate" FROM "categories"
2020-10-17 09:45:49.278 UTC [2275] ERROR:  operator does not exist: text ->> unknown at character 322
2020-10-17 09:45:49.278 UTC [2275] HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
2020-10-17 09:45:49.278 UTC [2275] STATEMENT:  SELECT "categories"."id" AS "categories_id", "categories"."name" AS "categories_name", "categories"."name_pl" AS "categories_name_pl", "categories"."is_free" AS "categories_is_free", "categories"."updated_at" AS "categories_updated_at", "categories"."created_at" AS "categories_created_at" FROM "categories" ORDER BY name->>'name_pl' ASC LIMIT 30 OFFSET 0