You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Or more concrete: I have tables that have composite primary keys (can't do anything about it) whose columns also aren't necessarily numeric. It appears that when a cursor object is not given, cursorstream will default to a cursor of { id: number } which doesn't exist on many of my tables.
I have attached the implementation I'm currently using to work around this. Typescript is set somewhat differently for this project, so ignore the whitespace, semicolon and some linter comments when comparing. The most important changes are:
the A type is no longer optional (this conflicts with Allow findManyArgs to be undefined #2) and requires the cursor part to be set. Also notice the documentation comment about the actual provided values for this cursor being completely irrelevant.
cursorField is now cursorFields
cursorValue is now of the cursor type
I did not make this a PR because aside from the conflict, there's several issues/things that can probably be improved:
Typescript can probably be made happier (less linter suppression), especially around cursorFields and its usages
Giving a cursor with garbage values is a bit weird, though the release version also has this behaviour if a cursor is given
I haven't found a way to get the primary key field(s) dynamically, which is a shame because it's probably over 90% of my usecase. Providing some garbage cursor values for the few times I use some unique key other than the primary would make the code a lot better than having to provide them all the time. It would probably also solve the weird id hardcoding?
I'm not expecting this to get merged because { id: number } is what is used by most sane databases. It's also fine if this gets closed, but I wanted to at least get these changes out there. That way, someone else running into the same problem can reuse this, and/or the good parts/ideas can be cherry-picked.
CursorStreamExtension.ts.txt
(just remove the .txt part from the attachment name, I had to add it because github was unhappy with .ts)
Or more concrete: I have tables that have composite primary keys (can't do anything about it) whose columns also aren't necessarily numeric. It appears that when a cursor object is not given, cursorstream will default to a cursor of
{ id: number }which doesn't exist on many of my tables.I have attached the implementation I'm currently using to work around this. Typescript is set somewhat differently for this project, so ignore the whitespace, semicolon and some linter comments when comparing. The most important changes are:
Atype is no longer optional (this conflicts with AllowfindManyArgsto be undefined #2) and requires thecursorpart to be set. Also notice the documentation comment about the actual provided values for this cursor being completely irrelevant.cursorFieldis nowcursorFieldscursorValueis now of the cursor typeI did not make this a PR because aside from the conflict, there's several issues/things that can probably be improved:
idhardcoding?I'm not expecting this to get merged because
{ id: number }is what is used by most sane databases. It's also fine if this gets closed, but I wanted to at least get these changes out there. That way, someone else running into the same problem can reuse this, and/or the good parts/ideas can be cherry-picked.CursorStreamExtension.ts.txt
(just remove the
.txtpart from the attachment name, I had to add it because github was unhappy with.ts)