Now I have another thing, if I use `QueryDsl.inser...
# komapper
d
Now I have another thing, if I use
QueryDsl.insert(...).single(Foo(id=100, ...))
, will the id be 100? It seems like it just ignores the number I pass (I thought it only ignores 0...)?
t
If you have configured your entity class for auto-increment, then you cannot provide an ID.
d
🤕 There's really no way at all? Maybe even using set { }?
I want it to auto-increment, but for tests I really need to override it, I'm trying to migrate to Komapper from Exposed, but I don't really want to rewrite hundreds of lines of test code...
t
I’ll think about how to address this. By the way, some RDBMS require special settings to assign values to auto-increment columns. Which RDBMS are you using?
d
I need postgres and mysql for this project, but currently I'm using postgres (those are the dialects... but my tests are running on H2 with compatibility mode enabled and I'm using the corresponding Komapper dialects for postgres or mysql with h2)
Exposed managed to do this...
t
Can you show me the code?
d
The insert code or db initialization code?
t
It’s the code corresponding to an INSERT statement that sets a value for an auto-increment column.
d
It's really something like
QueryDsl.insert(...).single(Foo(id=100, ...))
... but I can't really post the actual code
👍 1
There's no temporary workaround for this is there...?
t
It might not be the best idea, but I think it would be good to create a different entity definition.
d
That would maybe be a solution... but it's quite messy to manage...
Maybe have
@KomapperAutoIncrement(allowOverride=true)
or maybe even ``@KomapperAutoIncrement(autoGenerateValueIf=0)` (that any other value other than 0 will be written, whereas 0 will just auto-increment...)