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 panic when unsupported #31

Open
kellymtrinh opened this issue May 31, 2022 · 0 comments
Open

ColumnType methods panic when unsupported #31

kellymtrinh opened this issue May 31, 2022 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@kellymtrinh
Copy link

kellymtrinh commented May 31, 2022

Describe the bug

When using this driver with the go sql package, ColumnType.DatabaseTypeName, ScanType, Length, and DecimalSize panics when a column type is unsupported.

Could this return the nil values as appropriate when it's not supported, to match what is described here: "If an empty string is returned, then the driver type name is not supported."?

Current behavior 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.

To Reproduce

func TestMakeGoLangUnsupportedType(t *testing.T) {
	makeGoLangTypeName(typeInfo{TypeId: 123})

}
// --- FAIL: TestMakeGoLangTypeName1 (0.00s)
// panic: not implemented makeGoLangTypeName for type 123 [recovered]
// 	panic: not implemented makeGoLangTypeName for type 123

Expected behavior
Instead of a panic, it should return nil values as appropriate for callers to handle.

Further technical details

The panic happens in makeGoLangTypeName, which is used in ColumnTypeScanType and ColumnTypeScanType.
The other methods can be found in types.go too.

@kellymtrinh kellymtrinh changed the title DatabaseTypeName panics with unsupported column types instead of returning empty string ColumnType methods panic when unsupported Jun 1, 2022
@shueybubbles shueybubbles added bug Something isn't working good first issue Good for newcomers labels Jun 9, 2022
@grrlgeek grrlgeek added this to the Backlog milestone May 22, 2023
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
None yet
Development

Successfully merging a pull request may close this issue.

3 participants