Skip to content

proposal: database/sql: ScannerContext, ValuerContext support #40511

@jinzhu

Description

@jinzhu

Currently when using Scanner, Valuer interface with database/sql, it can't behave differently based on the current context

For example, in a multi-tenant system, each tenant has a different encryption key and would like to save the encrypted value and retrieve the decrypted value automatically.

If we can support ScannerContext and ValuerContext interface in the package database/sql, it would be much easier to implement those cases.

// option 1
type ScannerContext interface {
  Scan(ctx context.Context, src interface{}) error
}

type ValuerContext interface {
	Value(ctx context.Context) (Value, error)
}

// option 2
type ScannerContext interface {
  ScanContext(ctx context.Context, src interface{}) error
}

type ValuerContext interface {
	ValueContext(ctx context.Context) (Value, error)
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions