Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@the-infinite
Copy link

@the-infinite the-infinite commented Dec 8, 2025

The Bug (#2788)

When using the query API to interact with a postgres database, irrespective of the driver, I was always getting an error about the offset being out of bounds of the DataView. I was typically working around it by using the select APIs instead.

The Cause

During my investigation, I found out that the cause of the issue was a data contract violation in the parseEWKB function in the file drizzle-orm/src/pg-core/columns/postgis_extension/utils.ts. The function was expecting that the value passed to it would always be a hex string but I found out that was not the case. During testing, I discovered that there were cases where a GeoJSON object was passed to it instead.

Therefore, I added a function to validate that the input is in fact a hex string before processing the content as a hex string. I also added support for directly using GeoJSON object strings and GeoJSON objects.

Testability

In order to ensure backward compatibility and confirm that the fixes did work, I augmented the integration tests in the integration-tests/tests/extensions/postgis/postgres.test.ts and integration-tests/tests/extensions/postgis/pg.test.ts. The included test cases cover query for tables containing geometry data and queries with relations for tables containing geometry data.

I can confirm that these tests both completed successfully as shown in the image below.

Screenshot From 2025-12-08 11-53-32

Next Steps

While this pull request technically does "fix" #2788, it is nothing more than a patch or a hot fix. It does not really try to find out the root cause and just addresses the issues that exist at the surface.

I made this PR because I use drizzle a lot because I love it, and I know first hand how much of a pain this issue creates. I wanted to at least provide a quick fix for all of the other people that are using drizzle in production like me and are impeded by this issue like myself.

Conclusion

Please do not hesitate to reach out to me if you have any questions or comments you have for me. I would be delighted to provide my support in any meaningful capacity.

…N support (Fixes drizzle-team#2788)

Added a function to validate hex strings and improved error handling for GeoJSON parsing.
@the-infinite the-infinite changed the title [Pg] Handle Data Type Conflicts in parseEWKB [Pg] Handle Data Type Conflicts in parseEWKB (Fixes #2788) Dec 8, 2025
@the-infinite the-infinite changed the title [Pg] Handle Data Type Conflicts in parseEWKB (Fixes #2788) [Pg] Handle Data Type Conflicts in parseEWKB Dec 8, 2025
@melleg
Copy link

melleg commented Dec 10, 2025

Fantastic! I hope this gets merged quick.

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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.