Skip to content

Commit

Permalink
fix: remove escape pagination keys and use double quote instead
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin658 committed Feb 1, 2021
1 parent a074e13 commit dc75226
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const queryBuilder = getConnection()

const paginator = buildPaginator({
entity: User,
paginationKeys: ['id'],
query: {
limit: 10,
order: 'ASC',
Expand Down Expand Up @@ -71,6 +72,7 @@ interface Cursor {
```typescript
const nextPaginator = buildPaginator({
entity: User,
paginationKeys: ['id'],
query: {
limit: 10,
order: 'ASC',
Expand All @@ -86,6 +88,7 @@ const { data, cursor } = await nextPaginator.paginate(queryBuilder);
```typescript
const prevPaginator = buildPaginator({
entity: User,
paginationKeys: ['id'],
query: {
limit: 10,
order: 'ASC',
Expand Down
4 changes: 2 additions & 2 deletions src/Paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ export default class Paginator<Entity> {
let query = '';
this.paginationKeys.forEach((key) => {
params[key] = cursors[key];
where.orWhere(`${query}${escape(this.alias)}.${escape(key)} ${operator} :${key}`, params);
query = `${query}${escape(this.alias)}.${escape(key)} = :${key} AND `;
where.orWhere(`${query}${escape(this.alias)}."${key}" ${operator} :${key}`, params);
query = `${query}${escape(this.alias)}."${key}" = :${key} AND `;
});
}

Expand Down

0 comments on commit dc75226

Please sign in to comment.