Hi David,

Thanks for your message.

Some RDBMS support nullable primary keys. Others support deferred
constraints (which jOOQ is currently unaware of), and even if both things
are not supported, there might still be an identity or a trigger-generated
value in your primary key constraint, in case of which it is not
unreasonable to have null values prior to inserting a record. In addition
to that, you could be left-joining a table, and its primary key column
values would be null for this result set, despite them not being null in
the database. This is no different from what we've discussed before on this
list:
https://groups.google.com/g/jooq-user/c/vwKYEK1CFDI/m/TPe2C5etBAAJ

I'm aware that we might be discussing an 80/20 situation here. In 80% (or
even more) of the cases, what you're expecting is reasonable, and you're
willing to risk running into NPEs in those 20% of the cases I've mentioned
above (or even less). We will be offering additional flags in the code
generator, which allow you to override this behaviour in the future:
https://github.com/jOOQ/jOOQ/issues/10212

But for now, the correct way is the only way.

Thanks,
Lukas

On Mon, Nov 9, 2020 at 5:06 PM David Karlsen <[email protected]> wrote:

> The generated code looks like:
>
> // -------------------------------------------------------------------------
> // Primary key information
> // -------------------------------------------------------------------------
>
> override fun key(): Record2<String?, String?> = super.key() as 
> Record2<String?, String?>
>
>
> but I guess it should be Record2<String,String> since no part of the key
> should be allowed to be null for a pk?
>
> Using 3.14.2
>
>
> --
> David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jooq-user/CAGO7Ob1OQ6Q0x4B1cRxYRQ2oVcjptrKTXPcd35T6RNXdFvrvYg%40mail.gmail.com
> <https://groups.google.com/d/msgid/jooq-user/CAGO7Ob1OQ6Q0x4B1cRxYRQ2oVcjptrKTXPcd35T6RNXdFvrvYg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/CAB4ELO7DVt-KSEpcE16KY_ih1iwGPjMK6by25kpxmSMHYNSVqA%40mail.gmail.com.

Reply via email to