Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ColumnType methods should not panic if column type is unimplemented #32

Closed

Conversation

kellymtrinh
Copy link

@kellymtrinh kellymtrinh commented May 31, 2022

For issue: #31

ColumnType methods should return nil values instead of panicking when column types are unimplemented. Current behavior, which panics, means calling ColumnTypes() or related methods in the database/sql lib panics if I'm doing something like select * on a table with an unsupported column (or trying to use the driver for generic queries). Matching the spec would let clients handle the cases.

This matches the documentation in the database/sql package for drivers:

  • makeGoLangTypeName -> used in DatabaseTypeName: "If an empty string is returned, then the driver type name is not supported. "
  • makeGoLangScanType -> used in ScanType: "If a driver does not support this property ScanType will return the type of an empty interface."
  • makeGoLangTypeLength -> Length: " if not supported by the driver ok is false."
  • makeGoLangTypePrecisionScale -> precision " If not applicable or if not supported ok is false."

@ghost
Copy link

ghost commented May 31, 2022

CLA assistant check
All CLA requirements met.

@kellymtrinh kellymtrinh changed the title Return ColumnType methods should not panic if column type is unimplemented May 31, 2022
@kellymtrinh kellymtrinh marked this pull request as ready for review May 31, 2022 21:22
@kellymtrinh kellymtrinh marked this pull request as draft May 31, 2022 21:30
@kellymtrinh kellymtrinh marked this pull request as ready for review June 1, 2022 01:18
@shueybubbles shueybubbles added bug Something isn't working good first issue Good for newcomers labels Jun 8, 2022
@@ -1114,7 +1114,7 @@ func makeGoLangScanType(ti typeInfo) reflect.Type {
case typeVariant:
return reflect.TypeOf(nil)
default:
panic(fmt.Sprintf("not implemented makeGoLangScanType for type %d", ti.TypeId))
return reflect.TypeOf(new(interface{})).Elem()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move this common code into a helper function that also logs the type name so developers can see when this is happening if they hook up driver logs in their app.

@stuartpa stuartpa linked an issue Jun 13, 2022 that may be closed by this pull request
@stuartpa stuartpa self-requested a review June 15, 2022 11:10
@shueybubbles
Copy link
Collaborator

Please add a test that shows the application-level change this enables. What functionality does this light up ?

@shueybubbles
Copy link
Collaborator

Please update changelog.md in the root with a description of the change.

@shueybubbles
Copy link
Collaborator

@kellymtrinh Are you still planning to complete this PR?

thx

@kellymtrinh
Copy link
Author

Closing because I will not be able to pick this up again soon. Appreciate the review and I still think this is a good first issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
V1
Awaiting triage
Development

Successfully merging this pull request may close these issues.

ColumnType methods panic when unsupported
2 participants