Skip to content

Introduce a DBSequence typeclass for sequence DB types - #418

Merged
TeofilC merged 1 commit into
masterfrom
wip/dbseq
Sep 23, 2026
Merged

TeofilC merged 1 commit into
masterfrom
wip/dbseq

Conversation

@TeofilC

@TeofilC TeofilC commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

We add a new DBSequence typeclass to track database types that can be used in sequences. This is basically all sizes of
integers (Int16,Int32,Int64). They are the types that nextval can generate.

Previously we forced this to be only Int64.

It's up to the user to ensure that the correct type is being used with the correct postgres sequence.

Resolves #328

@ocharles ocharles left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the point of the class is we can derive DBSequence for something like UserId? Does that work if the underlying DBType talks about a domain type (like our use user_id in our production database`)?

Comment thread changelog.d/20260921_150002_teofilcamarasu_dbseq.md
@TeofilC

TeofilC commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Does that work if the underlying DBType talks about a domain type (like our use user_id in our production database`)?

I see, we have a DOMAIN type. I think that should work fine, or at least, this isn't doing anything particularly different to what we already do and that works?

@TeofilC

TeofilC commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

I wonder if I should just move nextval into the typeclass? And then users could override it if they so chose? Or is that a footgun?

We add a new DBSequence typeclass to track database types that can be
used in sequences. This is basically all sizes of
integers (Int16,Int32,Int64). They are the types that `nextval` can generate.

Previously we forced this to be only Int64.

It's up to the user to ensure that the correct type is being used with
the correct postgres sequence.
@ocharles

Copy link
Copy Markdown
Contributor

Hard to say! Maybe for now keep this as you have it

@TeofilC
TeofilC merged commit f8b5431 into master Sep 23, 2026
3 checks passed
@TeofilC
TeofilC deleted the wip/dbseq branch September 23, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Insert with defaults: nextval doesn't handle newtype-wrapped Id

2 participants