Skip to content

Allow custom functions to return nonzero BLOB#121

Open
jyopp wants to merge 1 commit into
crawshaw:masterfrom
jyopp:context-blobs
Open

Allow custom functions to return nonzero BLOB#121
jyopp wants to merge 1 commit into
crawshaw:masterfrom
jyopp:context-blobs

Conversation

@jyopp

@jyopp jyopp commented Apr 22, 2021

Copy link
Copy Markdown

Context lacks the expected method ResultBlob for nonzero blobs, even though it implements ResultZeroBlob for zeroed blobs of arbitrary size. As a result, custom functions cannot currently return []byte results, such as cryptographic hashes.

@BrannonKing

Copy link
Copy Markdown

Fixes #124

@AdamSLevy AdamSLevy added the enhancement New feature or request label Nov 6, 2021

@AdamSLevy AdamSLevy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. minor nit in the tests.

Comment thread func_test.go
if stmt.ColumnBytes(0, got) != len(want) || !bytes.Equal(got, want) {
t.Errorf("blobcat(x'ff00',x'00ba')='%x', want '%x'", got, want)
}
stmt.Finalize()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defer this after line 155 please

Comment thread func_test.go
if got, want := stmt.ColumnText(0), "strcat"; got != want {
t.Errorf("strcat('str','','cat')='%s', want '%s'", got, want)
}
stmt.Finalize()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment thread func_test.go
t.Fatal("Error does not match expected description")
}

stmt.Finalize()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants