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

Add support for client-side DataType validation #4543

Closed
lukaseder opened this issue Sep 14, 2015 · 3 comments
Closed

Add support for client-side DataType validation #4543

lukaseder opened this issue Sep 14, 2015 · 3 comments

Comments

@lukaseder
Copy link
Member

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 of DOMAINs (see Add support for type DOMAINs #681)
  • Correct validation in the presence of triggers
  • 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


See also:

@rgoldberg
Copy link

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.

@lukaseder
Copy link
Member Author

Good point. This is similar to Param.setValue(T) and Param.setConverted(Object).

@lukaseder
Copy link
Member Author

I don't think we should implement this, after all.

3.16 Other improvements automation moved this from To do to Done Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

2 participants