Allow to use empty typeMap on Connection#183
Merged
Mytherin merged 1 commit intoduckdb:mainfrom Apr 8, 2025
Merged
Conversation
`Connection#getTypeMap()` and `setTypeMap()` are two legacy methods that were added to Java in 1998 to support mapping composite DB fields to custom Java classes. With widespread use or object-relational mapping libraries (like Hibernate) these method remain virtually unused in Java applications. Still these method may be called by some tools, for example, when doing DB schema introspection. Looking how these methods work in other JDBC drivers, we can see that in Postgres' `pgjdbc` the type map is accepted, but not used for actual field mapping. And in SQL Server's `mssql-jdbc` only empty type map is accepted and empty type map is always returned. It is proposed to follow SQL Server's approach to not throw on `getTypeMap()` and to allow empty map input in `setTypeMap()`. Note: CMake change is unrelated, it is added to unbreak CI builds before duckdb#178 fix (or its variation from other PRs) is merged. Testing: new test added that checks that empty type map is allowed. Fixes: duckdb#150
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connection#getTypeMap() and setTypeMap() are two legacy methods that were added to Java in 1998 to support mapping composite DB fields to custom Java classes. With widespread use or object-relational mapping libraries (like Hibernate) these method remain virtually unused in Java applications. Still these method may be called by some tools, for example, when doing DB schema introspection.
Looking how these methods work in other JDBC drivers, we can see that in Postgres'
pgjdbcthe type map is accepted, but not used for actual field mapping. And in SQL Server'smssql-jdbconly empty type map is accepted and empty type map is always returned.It is proposed to follow SQL Server's approach to not throw on
getTypeMap()and to allow empty map input insetTypeMap().Note: CMake change is unrelated, it is added to unbreak CI builds before #178 fix (or its variation from other PRs) is merged.
Testing: new test added that checks that empty type map is allowed.
Fixes: #150