We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
1.15.0
I have an Entity that I want to either select all or filter by mode. The SQL looks like this:
SELECT * FROM entity WHERE (mode IN (sqlc.narg(mode)) OR sqlc.narg(mode) IS NULL)
This generates a struct called NullMode and a Value() function for it
Value()
type Mode string type NullMode struct { Mode Mode Valid bool // Valid is true if String is not NULL } func (ns NullMode) Value() (driver.Value, error) { if !ns.Valid { return nil, nil } return ns.Mode, nil }
Now when this gets executed I am getting the following Error-Message:
sql: converting argument $1 type: non-Value type analytics.Mode returned from Value
This can be easily fixed by adding a string-cast to the Value-Return like this:
return string(ns.Mode), nil
No response
CREATE TYPE mode AS ENUM ( 'live', 'shadow' ); CREATE TABLE entity ( id SERIAL PRIMARY KEY, mode mode NOT NULL DEFAULT 'shadow' )
macOS
PostgreSQL
Go
The text was updated successfully, but these errors were encountered:
fix: the enum Value method returns correct type
9062c70
The Value method must returns nil or the following types: * int64 * float64 * bool * []byte * string * time.Time Closes: sqlc-dev#1880
fix: the enum Value method returns correct type (#1996)
4311c22
The Value method must returns nil or the following types: * int64 * float64 * bool * []byte * string * time.Time Closes: #1880
Successfully merging a pull request may close this issue.
Version
1.15.0
What happened?
I have an Entity that I want to either select all or filter by mode. The SQL looks like this:
This generates a struct called NullMode and a
Value()
function for itNow when this gets executed I am getting the following Error-Message:
This can be easily fixed by adding a string-cast to the Value-Return like this:
Relevant log output
No response
Database schema
SQL queries
No response
Configuration
No response
Playground URL
No response
What operating system are you using?
macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go
The text was updated successfully, but these errors were encountered: