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

Insert/Update for boolean fields fails in MSSQL #695

Closed
srs opened this issue Oct 27, 2022 · 2 comments · Fixed by #697
Closed

Insert/Update for boolean fields fails in MSSQL #695

srs opened this issue Oct 27, 2022 · 2 comments · Fixed by #697

Comments

@srs
Copy link
Contributor

srs commented Oct 27, 2022

When trying to insert or update a record in MSSQL using MSSQL dialect it fails. The reason is that BUN creates an SQL with TRUE or FALSE which is not supported in MSSQL. The recomended type for using boolean in MSSQL is a BIT-type.

Is it a way for this to work with current BUN version? I do not want to change the entity field to use a number instead of a boolean. It would be nice to let BUN do this work instead of customizing our domain objects to support MSSQL.

@srs
Copy link
Contributor Author

srs commented Oct 27, 2022

I see that AppendBool is not implemented in a dialect, but just directly used. It would be good if AppendBool would be in the dialect interface so it can be implemented in MSSQL-dialect as a number.

Current implementation:

func AppendBool(b []byte, v bool) []byte {
	if v {
		return append(b, "TRUE"...)
	}
	return append(b, "FALSE"...)
}

@srs
Copy link
Contributor Author

srs commented Oct 27, 2022

See #697 for pull request.

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 a pull request may close this issue.

1 participant