typeorm-cursor-pagination: unknown type in cursor: [object]
Hi there! This library is awesome. It’s working great for most use cases I’ve encountered. However, I’m getting a weird error from the internals of the library occasionally when querying against test fixtures that were inserted into my local database by other tests prior to my test running. The column on which I’m trying to paginate has the PG type timestamp
.
The entity is defined as follows:
@Column({
type: 'timestamp',
nullable: true,
})
videoDisplayTime!: Date | null;
Here’s the error coming out of the test run, with internals snipped out.
Error: unknown type in cursor: [object]Mon Nov 23 2020 18:23:15 GMT+0000 (Coordinated Universal Time),at Object.encodeByType ([snip]/node_modules/typeorm-cursor-pagination/src/utils.ts:23:13),at payload.paginationKeys.map ([snip]/node_modules/typeorm-cursor-pagination/src/Paginator.ts:178:21),at Array.map (<anonymous>),at Paginator.encode ([snip]/node_modules/typeorm-cursor-pagination/src/Paginator.ts:176:41),at Paginator.<anonymous> ([snip]/node_modules/typeorm-cursor-pagination/src/Paginator.ts:92:35),at Generator.next (<anonymous>),at fulfilled ([snip]/node_modules/typeorm-cursor-pagination/lib/Paginator.js:5:58),at process._tickCallback (internal/process/next_tick.js:68:7)
--
body: {
"status": 500,
"errorName": "Error",
"message": "unknown type in cursor: [object]Mon Nov 23 2020 18:23:15 GMT+0000 (Coordinated Universal Time)",
"stack": [
"at Object.encodeByType ([snip]/node_modules/typeorm-cursor-pagination/src/utils.ts:23:13)",
"at payload.paginationKeys.map ([snip]/node_modules/typeorm-cursor-pagination/src/Paginator.ts:178:21)",
"at Array.map (<anonymous>)",
"at Paginator.encode ([snip]/node_modules/typeorm-cursor-pagination/src/Paginator.ts:176:41)",
"at Paginator.<anonymous> ([snip]/node_modules/typeorm-cursor-pagination/src/Paginator.ts:92:35)",
"at Generator.next (<anonymous>)",
"at fulfilled ([snip]/node_modules/typeorm-cursor-pagination/lib/Paginator.js:5:58)",
"at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
Any ideas on what I we may be doing wrong would be greatly appreciated!
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (7 by maintainers)
I set up a contrived example. I believe the issue is with the naming strategy. This pagination library doesn’t seem to use the naming strategy set in the TypeOrm configuration to derive proper column names for its pagination keys.
https://github.com/mividtim/pagination-test
Repro steps:
yarn
ornpm install
.sample.env
to.env
..env
to point to your local DByarn start:dev
construed
array.yarn migration:up
to populate theconstrued
table with some test data.construed
property)