You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, jOOQ offers no way to validate data types like VARCHAR(length), NUMBER(precision, scale), or UNSIGNED INTEGER on the client side. It would be useful to be able to:
Turn on/off automatic validation when binding variables to such types
Implement custom validators via a new SPI
One of the main reasons why this doesn't exist yet is the great amount of edge-cases that are perhaps not possible to implement correctly at the client side:
Correct validation in the case of expressions, such as concatenation, arithmetic, etc
There might still be a low-hanging fruit, though. As suggested by Ross, we could at least add something like DataType.validate(T) and DataType.validateConverted(Object) (or similar) to run explicit (not automatic) client side data type validation. Binding implementors would need to implement validation for their DataType
You might want to change the argument type for DataType#validate(T) from T to Object, since, e.g., if in MySQL you set a varchar column to a numeric value (in jOOQ, e.g., a DataType<String> & an Integer, respectively), it will automatically convert the number into a varchar.
If you want to allow people to have compile-time checking for "correct" classes being used with a DataType<T>, then you could have two methods:
DataType#validateStrict(T)
DataType#validateLenient(Object)
I prefer the two method approach, since each could be useful in different circumstances.
Currently, jOOQ offers no way to validate data types like
VARCHAR(length)
,NUMBER(precision, scale)
, orUNSIGNED INTEGER
on the client side. It would be useful to be able to:One of the main reasons why this doesn't exist yet is the great amount of edge-cases that are perhaps not possible to implement correctly at the client side:
DOMAINs
(see Add support for type DOMAINs #681)There might still be a low-hanging fruit, though. As suggested by Ross, we could at least add something like
DataType.validate(T)
andDataType.validateConverted(Object)
(or similar) to run explicit (not automatic) client side data type validation.Binding
implementors would need to implement validation for theirDataType
See also:
The text was updated successfully, but these errors were encountered: