Skip to content

Allow to use empty typeMap on Connection#183

Merged
Mytherin merged 1 commit intoduckdb:mainfrom
staticlibs:typemap_stub
Apr 8, 2025
Merged

Allow to use empty typeMap on Connection#183
Mytherin merged 1 commit intoduckdb:mainfrom
staticlibs:typemap_stub

Conversation

@staticlibs
Copy link
Collaborator

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 #178 fix (or its variation from other PRs) is merged.

Testing: new test added that checks that empty type map is allowed.

Fixes: #150

`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
@Mytherin Mytherin merged commit c0e947f into duckdb:main Apr 8, 2025
7 checks passed
@Mytherin
Copy link
Contributor

Mytherin commented Apr 8, 2025

Thanks!

@staticlibs staticlibs deleted the typemap_stub branch April 8, 2025 16:15
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 this pull request may close these issues.

JDBC driver should support getTypeMap()

2 participants