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 own enumeration of data types to API #2194

Closed
katzyn opened this issue Oct 21, 2019 · 3 comments · Fixed by #2409
Closed

Add own enumeration of data types to API #2194

katzyn opened this issue Oct 21, 2019 · 3 comments · Fixed by #2409

Comments

@katzyn
Copy link
Contributor

katzyn commented Oct 21, 2019

In JDBC 4.2 integer constants from java.sql.Types have better alternative: a java.sql.SQLType interface. There is a JDBCType implementation that is equivalent to SQLType and each database can have an own implementation with own types.

I think we need to create such implementation (possibly an enumeration) in org.h2.api package and list all own data types (including intervals, geometries, JSON, etc.) in it.

@grandinj
Copy link
Contributor

sounds good

@katzyn
Copy link
Contributor Author

katzyn commented Oct 21, 2019

Such vendor-specific types have textual names, but they still need some integer constants. I don't want to use constants from Value for that purpose, because they historically have strange order, for example, datetime values with time zones are far from other datetime data types. They aren't required to be sequential, any integer values may be used, we may leave gaps between each category of values for possible expansion in the future.

In the source code names and numbers aren't normally used, because there are no lookup methods for them. If we create an own enumeration, its constants will be used as is and it doesn't really matter how getName() and getVendorTypeNumber() will be implemented. But it's better to return some fixed numbers that aren't going to be changes in the future releases of H2.

@katzyn
Copy link
Contributor Author

katzyn commented Oct 21, 2019

Oracle's driver uses Integer.MIN_VALUE for all strange data types.

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

Successfully merging a pull request may close this issue.

2 participants