Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoIncrement with not nullable mapped column #136

Closed
joseluisgs opened this issue May 14, 2023 · 3 comments
Closed

autoIncrement with not nullable mapped column #136

joseluisgs opened this issue May 14, 2023 · 3 comments
Milestone

Comments

@joseluisgs
Copy link

One of the best things about using Kotlin is being able to work with nulls safely.

I wanted to know, if I can work with autoIncrement directly in my model without the need to make id nullable.

Other frameworks use for example -1 or 0.

I think it's better to avoid comparison problems later or use !!.

Currently I solve it using a another bridge class, but I find it unnecessary if a non-null default value can be used.

Is there another possibility?

@pull-vert pull-vert added this to the 3.1.1 milestone May 24, 2023
@pull-vert
Copy link
Contributor

Hello @joseluisgs
Thanks for submitting this proposal, I understand your point of view.
For me a nullable id for an autoincrement column is the natural way to go : it's null unless you affect a value yourself or it's returned from a insertAndReturn call, this null value has a clear meaning that your entity was not inserted yet.

But nothing prevent me to allow autoIncrement for non nullable columns too, I would have to ignore the column value if it is <= 0 to let the database generate a value in this case.
I add it to the roadmap !

@pull-vert pull-vert modified the milestones: 3.2.1, 3.2.2 Sep 11, 2023
@pull-vert pull-vert changed the title autoIncrement without not null autoIncrement with not nullable mapped column Jan 31, 2024
@pull-vert
Copy link
Contributor

Hi @joseluisgs
This feature is included in the latest 3.2.2 version that was released yesterday

@joseluisgs
Copy link
Author

@pull-vert Thank you very much! You are the best!

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

No branches or pull requests

2 participants