Skip to content

Support for JSONB data types #3

@jagregory

Description

@jagregory

Hey, thanks for this library, it's super promising. I've been using it for schema changes so far, but when I attempted to use it for an actual insert query I hit an issue with my JSONB columns. Is there a way to use JSONB at the moment or is it unsupported?

I had a poke around (after receiving a wtf error from here 😅) and if I hacked the serialization for object I could make it work, though I'm not sure if it's actually the right way to do it:

case "object":
  if (Buffer.isBuffer(value))
    return {
      blobValue: value,
    };
  else
    return {
      stringValue: JSON.stringify(value);
    };

I also wondered about the typeHint property for the SqlParameter, which can be set to JSON to indicate the stringValue contains JSON. I didn't actually do this and it all worked fine anyway, but perhaps the serialize could be updated to return a SqlParameter with the hint rather than just the value itself.

Edit: Ignore the above, it wasn't actually working against a real database, just locally. Ooops.

I'm interested to hear your thoughts on this. I'm happy to send a PR if you can give me some direction.

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