From fb74d84cb75fae55c0fb70764a1b9a1e243f7658 Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Wed, 9 Aug 2023 09:16:10 -0500 Subject: [PATCH] Map names to db ident names for columns passed for ordering in paginated queries. --- fiber_orm.nimble | 2 +- src/fiber_orm.nim | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fiber_orm.nimble b/fiber_orm.nimble index 4f8fecb..12e1612 100644 --- a/fiber_orm.nimble +++ b/fiber_orm.nimble @@ -1,6 +1,6 @@ # Package -version = "2.1.1" +version = "2.2.0" author = "Jonathan Bernard" description = "Lightweight Postgres ORM for Nim." license = "GPL-3.0" diff --git a/src/fiber_orm.nim b/src/fiber_orm.nim index 3dfae1d..70d6955 100644 --- a/src/fiber_orm.nim +++ b/src/fiber_orm.nim @@ -438,7 +438,7 @@ template findRecordsWhere*[D: DbConnType]( if page.isSome: let p = page.get if p.orderBy.isSome: - fetchStmt &= " ORDER BY " & p.orderBy.get + fetchStmt &= " ORDER BY " & identNameToDb(p.orderBy.get) else: fetchStmt &= " ORDER BY id" @@ -469,7 +469,7 @@ template getAllRecords*[D: DbConnType]( if page.isSome: let p = page.get if p.orderBy.isSome: - fetchStmt &= " ORDER BY " & p.orderBy.get + fetchStmt &= " ORDER BY " & identNameToDb(p.orderBy.get) else: fetchStmt &= " ORDER BY id" @@ -508,7 +508,7 @@ template findRecordsBy*[D: DbConnType]( if page.isSome: let p = page.get if p.orderBy.isSome: - fetchStmt &= " ORDER BY " & p.orderBy.get + fetchStmt &= " ORDER BY " & identNameToDb(p.orderBy.get) else: fetchStmt &= " ORDER BY id"