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

Support nullable foreign keys #153

Open
sengokudaikon opened this issue Apr 11, 2024 · 0 comments
Open

Support nullable foreign keys #153

sengokudaikon opened this issue Apr 11, 2024 · 0 comments

Comments

@sengokudaikon
Copy link

I would like to request adding support for nullable FKs. At least in Postgres, a FK that's nullable doesn't reference any PK and is therefore valid. This would allow mapping optional relations to the entities, as sometimes it's required.

protected fun <U : AbstractDbColumn<T, *>, V : Any?> U.nullableForeignKey(
        references: AbstractDbColumn<V, *>,
        fkName: String? = null,
    ): U =
        this.also {
            kotysaForeignKeys.add(ForeignKey(mapOf(this to references), fkName))
        }

maybe something like this?

If the feature is already possible to implement, please tell, because I couldn't find it in the documentation

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

1 participant