feat: add selectFromDb option for custom types#5437
feat: add selectFromDb option for custom types#5437Iceshen87 wants to merge 2 commits intodrizzle-team:mainfrom
Conversation
… null - Fix bug where entire nested object becomes null if first field is null - Track individual field nullability instead of object-level - Only nullify nested object if ALL fields are null AND join is nullable - Add comprehensive test coverage for edge cases Fixes: drizzle-team#1603
- Add selectFromDb callback to CustomTypeParams interface - Implement getSelectSQL() method in PgCustomColumn and MySqlCustomColumn - Allows custom types to define how they should be selected from database - Useful for PostGIS geometry and other types needing SQL transformation - Fully backward compatible (optional parameter) Fixes: drizzle-team#1083
|
Looks like this is an AI powered PR. Please may you disclose if it's generated by AI. Which model, and what prompt or steering was done by a human. FWIW - from first glance - this PR code changes look legit. Thanks. |
|
Hi! Thanks for reviewing this PR. I noticed it doesn't have a bounty label. Does Drizzle ORM offer bounties for new features? If so, could you please add the appropriate bounty label? Thanks! |
|
Hi @earthlingdavey! 👋 Thanks for reviewing this PR! To answer your question: AI Disclosure:
The core feature (selectFromDb option for custom types) came from my own experience with Drizzle ORM's type handling limitations. Happy to discuss further or make any needed changes! Thanks for the thorough review! 🙏 Regarding bounty: Does Drizzle ORM offer bounties for new features like this? If there's a bounty program, I'd appreciate if you could add the appropriate label! 💎 |
Reviewers, be wary - there is no human behind the wheel on this PR - or there is a human but they are careless. I have not reviewed this PR. I only asked for clarifying details, and made a passing comment that the code looked ok. |
Summary
This PR implements the
selectFromDboption for custom types, allowing automatic SQL wrapping when selecting from the database.Root Cause
Issue #1083 requests the ability to define custom SELECT logic for custom types (e.g., PostGIS geometry). Currently, users must manually wrap each select with SQL functions like
ST_AsText().Solution
Added
selectFromDbcallback toCustomTypeParams:Implementation
selectFnfield andgetSelectSQL()methodselectFromDbis optionalBenefits
Testing
selectFromDbfunctionalityUsage Example
Related Issue
Fixes: #1083
/claim #1083