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

VarChar and Char types lack ability to specify collation for parameters #129

Open
shueybubbles opened this issue Jul 14, 2023 · 0 comments
Labels
Always Encrypted Tasks related to implementation of AE

Comments

@shueybubbles
Copy link
Collaborator

func (s *Stmt) makeParamExtra(val driver.Value) (res param, err error) {
switch val := val.(type) {
	case VarChar:
		res.ti.TypeId = typeBigVarChar
		res.buffer = []byte(val)
		res.ti.Size = len(res.buffer)
	case VarCharMax:
		res.ti.TypeId = typeBigVarChar
		res.buffer = []byte(val)
		res.ti.Size = 0 // currently zero forces varchar(max)

Key problems:

  1. It's just sending the raw UTF8 bytes
  2. If the column is encrypted, the insert will always fail due to a type mismatch.
  3. The type aliases for string are too simplistic.

We can preserve backward compatibility of the aliases by allowing the app to specify a default collation for char and varchar types. We also need new types for per-parameter collation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Always Encrypted Tasks related to implementation of AE
Projects
None yet
Development

No branches or pull requests

2 participants