-
Notifications
You must be signed in to change notification settings - Fork 59
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
case insensitive uniqueness constraint #209
Comments
any updates on this? |
Well there's no actual proposal here for how to do this. Given the current design of the I suppose in principle we could introduce the notion of a "case-insensitive column" so you could write But I don't really see why you need this: you can easily ask JPA to include your own SQL script as part of schema export, and write your unique constraint by hand. |
Anyway, unless there is a concrete proposal for how to do this in an elegant way, my recommendation would be to simply close this issue. It doesn't seem to fit well with the model, and is super easy to accomplish in a different way. |
@gavinking hi! Thanks for getting back to me! I like your "case-insensitive column" idea: (Perhaps I should check with my team to see if they like it too but it's a long holiday weekend and I thought it would be better to give you feedback than risk immediate closure of this issue. Four of us were just at JavaOne a few weeks ago. We probably should have asked someone then!) 😄 I like how JPA abstracts away the details. Just add annotations and don't think too hard about what's going on under the covers. Please forgive me, but I'm not sure I understand "you can easily ask JPA to include your own SQL script as part of schema export, and write your unique constraint by hand." If we are regularly exporting our schema, I'm not aware of it, but I'm not the strongest database person on our team. (We do import or apply database migrations all the time with Flyway.) I just checked back on the Stack Overflow question I mentioned above and I don't see anyone suggesting this export solution. Perhaps someone reading this could add this as an answer and it could be upvoted as the best answer. Anyway, thanks again for the comments. I appreciate it. I'll show it to my team on Monday. |
@gavinking the consensus so far is that we like your |
So one thing I just noticed is that I doubt we need to require support for this, since only some databases allow it, but at least it's there as an option for implementations which want to support it. |
@pdurbin if this solution is acceptable, I'm inclined toward closing this issue. Remember that everyone always has the fallback option of specifying constraints in the |
So, look, I'm just going to declare that this statement is false, and that it's indeed possible to add such a constraint in JPA, by writing down the constraint in a SQL script, and using I don't think we should add official support for expressions in So finally I don't think we should do anything specific here. |
Hi! My understanding from https://stackoverflow.com/questions/25743191/how-to-add-a-case-insensitive-jpa-unique-constraint is that it is not possible to add a case insensitive uniqueness constraint in JPA. Is this correct? If so, can it be supported some day? As a workaround we add constraints in SQL like this (we're using PostgreSQL
The text was updated successfully, but these errors were encountered: