Skip to content

Conversation

@kprokopenko
Copy link
Collaborator

@kprokopenko kprokopenko commented Dec 25, 2025

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Custom types (type aliases) are not supported in parameter binding. Type handling code uses reflect.TypeOf() and has redundant type alias conversion logic.

Issue Number: N/A

What is the new behavior?

  • Added support for custom types (type aliases) in toValue() function
  • Replaced reflect.TypeOf() with reflect.TypeFor[T]() for type-safe type retrieval
  • Consolidated basic type handling into main switch statement
  • Removed redundant type alias conversion logic
  • Simplified code by using rv.Kind() directly

Other information

  • All existing tests pass
  • Added comprehensive tests for custom types
  • Maintains backward compatibility

@github-actions
Copy link

github-actions bot commented Dec 25, 2025

summary

Inferred base version: v3.125.0
Suggested version: v3.126.0

@codecov-commenter
Copy link

codecov-commenter commented Dec 25, 2025

Codecov Report

❌ Patch coverage is 83.22148% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.12%. Comparing base (87aeb90) to head (738ef17).

Files with missing lines Patch % Lines
internal/bind/params.go 81.73% 19 Missing and 2 partials ⚠️
internal/value/value.go 87.87% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1998      +/-   ##
==========================================
- Coverage   74.18%   74.12%   -0.06%     
==========================================
  Files         397      397              
  Lines       34737    34832      +95     
==========================================
+ Hits        25768    25820      +52     
- Misses       7850     7878      +28     
- Partials     1119     1134      +15     
Flag Coverage Δ
experiment 73.84% <83.22%> (+0.02%) ⬆️
go-1.21.x 73.01% <83.22%> (-0.07%) ⬇️
go-1.25.x 74.11% <83.22%> (-0.03%) ⬇️
integration 55.40% <28.85%> (-0.08%) ⬇️
macOS 47.70% <69.12%> (+0.03%) ⬆️
ubuntu 74.12% <83.22%> (-0.06%) ⬇️
unit 47.72% <69.12%> (+0.02%) ⬆️
windows 47.70% <69.12%> (+0.03%) ⬆️
ydb-24.4 54.83% <28.85%> (-0.09%) ⬇️
ydb-25.2 55.27% <28.85%> (+0.11%) ⬆️
ydb-latest 55.19% <28.85%> (+0.07%) ⬆️
ydb-nightly 73.84% <83.22%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Replace reflect.TypeOf with reflect.TypeFor for type-safe type retrieval
- Consolidate basic type handling into main switch statement
- Remove redundant type alias conversion logic
- Use rv.Kind() directly instead of separate kind variable
…rrectly

- Add basic type handling via reflect.Kind() in toType function
- Handle byte slices ([]byte and type aliases) as Bytes type instead of List
- Fix test failures for custom types
- Extract basic type handling to basicKindToType helper function
- Extract slice/array handling to sliceArrayToType helper function
- Extract map handling to mapToType helper function
- Extract struct handling to structToType helper function
- Extract concrete type handling to concreteTypeToType helper function
- Reduce cyclomatic complexity from 43 to acceptable level
- Extract reflect.Kind() handling logic to reflectKindToType function
- Keep original toType structure with concrete type switch
- Only new reflect-based functionality is extracted
- Keep toType in its original position after asSQLNullValue
- Place reflectKindToType immediately after toType
- This minimizes diff size by not moving the main toType function
- Modify test cases in params_test.go to create pointers from local variables instead of passing them directly to functions.
- This change improves clarity and avoids potential issues with variable lifetimes in the tests.
@kprokopenko kprokopenko requested a review from rekby December 25, 2025 12:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for custom types (type aliases) derived from primitive types in the database/sql driver's parameter binding functionality. The implementation refactors the type handling code to use reflection more efficiently and consolidates basic type handling logic.

  • Refactored type detection to support custom type aliases by using reflection-based kind checking
  • Consolidated basic type handling into the main switch statement using reflect.Value methods
  • Added comprehensive test coverage for custom type aliases across all primitive types

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
internal/bind/params.go Refactored toType() to extract reflection-based type detection into reflectKindToType(), and updated toValue() to handle custom types using reflection kind checking
internal/bind/params_test.go Added custom type definitions and comprehensive test cases covering all primitive type aliases including pointer and nil variants
CHANGELOG.md Added changelog entry documenting the new feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

asmyasnikov and others added 5 commits December 25, 2025 18:42
- Introduced derived types for various SQL data types to improve test coverage.
- Added test cases for int8, int16, int32, int64, uint8, uint16, uint32, uint64, float32, float64, bool, string, and byte slices.
- Each type includes both direct and derived type tests to ensure proper scanning behavior.
- Add castToDerivedType function to handle type aliases via reflection
- Support derived types for int32, uint64, float64, string, bool, bytes, and datetime
- Add integration test TestQueryDerivedTypesScan for QueryService
- Improve documentation with examples and limitations
- Unify datetimeValue derived type handling with castToDerivedType
- Optimize reflection calls in castToDerivedType
@github-actions
Copy link

🌋 SLO Test Results

Status: 🔴 7 workloads tested • 1 workloads failed

Workload Metrics Regressions Improvements Links
🟡 database-sql-table 9 0 0 ReportCheck
🟡 database-sql-query 9 0 0 ReportCheck
🔴 native-node-hints 9 0 1 ReportCheck
🟡 native-table-over-query-service 9 0 0 ReportCheck
🟡 native-bulk-upsert 9 0 0 ReportCheck
🟢 native-query 9 0 0 ReportCheck
🟢 native-table 9 0 0 ReportCheck

Generated by ydb-slo-action

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.

4 participants