Skip to content

Support hydrating specific Go types with function outputs #3225

Open
@rishi-kulkarni

Description

@rishi-kulkarni

What do you want to change?

One common use case I have a bit of trouble with is storing a blob of unstructured data as JSON in SQLite. I can use a column type override to scan this JSON into a Go struct and get the benefits of static typing in my application code.

Recently SQLite released the JSONB datatype, which is stored as a BLOB. To pull it out as JSON, you utilize the json_extract function with some JMESpath expression, like this:

create table if not exists test (data blob);

insert into test values(jsonb('{"a":2}'));

select json_extract(data, '$') from test;

As far as I can tell, there's no way to tell SQLC to stick the output of this function into a predefined struct, and it instead just comes out as interface{}. If there's no current way to specify this right now, it would be great to have some support in the future.

What database engines need to be changed?

PostgreSQL, MySQL, SQLite

What programming language backends need to be changed?

Go, Python, Kotlin

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions