Skip to content

Unable to use a zero value KSUID with a sql driver/database #79

@odannyc

Description

@odannyc

I'd like to pass all 0s to sql for querying, for example:

SELECT *
FROM users
WHERE id > '000000000000000000000000000';

This is not possible currently because this library treats a zero value ksuid as nil: https://github.com/segmentio/ksuid/blob/master/ksuid.go#L139-L144

func (i KSUID) Value() (driver.Value, error) {
	if i.IsNil() {
		return nil, nil
	}
	return i.String(), nil
}

Is there something I'm missing on how to pass 0s to sql or is it not possible? I'd like to avoid having to manage my own type which simply shadows the Value func if possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions