-
Notifications
You must be signed in to change notification settings - Fork 695
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
Custom null cases are difficult to work with. #1435
Comments
Can you please share the SQL you'd like to implement and the Exposed code you use? |
It's not quite a one off case as I have thousands of non-nullable columns in a database where I would like to handle a specific case as null in application code (a blank string). I would also like to be able to save null and have it translate to that value in the database. I need to do this across potentially many different column types as booleans and other types are saved as strings, but can in some cases can be nulled with a blank string. I also know if a column can have this "null" value or not. It's basically a null implementation in a database while avoiding builtin database features like the plague. The SQL would be pretty standard, something like To generalize this case I was attempting to create custom column types for these. I started out with the string case by creating an extension class off of
This mostly works. I can save nulls and they get converted to a blank string in the DB and regular strings are returned normally. Although, obviously not null checks would not work as expected and the column isn't actually nullable (I don't care too much about this), so saving an actual null to the database would fail. The problem comes when trying to retrieve a blank string from the database as null. They are returned as a blank strings because of
When a null is returned from the readObject method, it goes and re-runs the Thank you very much for your time! |
+1 We would like to use something similar for supporting "unknown" values of an |
It's the bug for sure. Thank you @naftalmm for PR. |
The use case where there is a value in a database that is equivalent to being a null (without the underlying column being null), is not possible with the library from my research. My specific use case is needing to interpret blank strings as a null value. I tired to implement a custom column type to do this, and extended the
IColumnType::readObject
method. This did not work as the result row ignores nulls returned from that method and instead runsgetObject
off of the JDBC ResultSet directly (This is in the ResultRow.create companion function). I also tried replicating how the current nullable works, but this did not seem to be possible from outside the library. Is my use case currently possible?The text was updated successfully, but these errors were encountered: