You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to mock a database query that returns rows containing a column of type []string (analogous to PostgreSQL's text[] field). However, even after implementing a custom ValueConverter to handle the []string type, I'm encountering a panic when adding rows with this type using sqlmock.NewRows(...).AddRow(...).
Error:
panic: row #1, column #3 ("obfuscation_fields") type []string: unsupported type []string, a slice of string
Steps to Reproduce:
Create a custom ValueConverter to handle the []string type:
In step 3. you are calling sqlmock.NewRows(..), which is using the driver.DefaultParameterConverter and causes the panic.
Using mock.NewRows(..) should give you the expected results: https://go.dev/play/p/7ZSsBDGeMtt
Description:
I'm trying to mock a database query that returns rows containing a column of type
[]string
(analogous to PostgreSQL'stext[]
field). However, even after implementing a customValueConverter
to handle the[]string
type, I'm encountering a panic when adding rows with this type usingsqlmock.NewRows(...).AddRow(...)
.Error:
Steps to Reproduce:
ValueConverter
to handle the[]string
type:[]string
column:Expected Behavior:
The mock should be able to handle rows with a
[]string
column without any issues.Actual Behavior:
A panic occurs indicating that the
[]string
type is unsupported.panic: row #1, column #3 ("obfuscation_fields") type []string: unsupported type []string, a slice of string [recovered]
Additional Context:
text[]
field.ValueConverter
, but I'm still facing the issue.The text was updated successfully, but these errors were encountered: