Skip to content

Support for SQLite binary BLOB type #10537

Closed
prisma/web
#3100

Description

@lambrospetrou

Problem

I am using SQLite for a few projects due to its simplicity and no need to maintain any infrastructure, but it seems that Prisma does not support its BLOB (binary) type.

I see that issue #1747 added support for the binary types in other database engines, but not SQLite. The docs also mention not supported.

sqlite not supported

Suggested solution

Not sure what the solution would look like, but similar to other engines supporting BLOB would be nice.

Activity

  1. janpio commented on Dec 2, 2021

    @janpio
    Contributor

    Related: #6666

  2. RobertCraigie commented on Dec 2, 2021

    @RobertCraigie

    Is this a documentation mismatch?

    generator client {
      provider = "prisma-client-js"
    }
    
    datasource client {
      provider = "sqlite"
      url      = "file:dev.db"
    }
    
    model Post {
      id     String @id @default(cuid())
      binary Bytes
    }

    Generated migration:

    -- CreateTable
    CREATE TABLE "Post" (
        "id" TEXT NOT NULL PRIMARY KEY,
        "binary" BLOB NOT NULL
    );

    Client script:

    import { PrismaClient } from "@prisma/client";
    
    const prisma = new PrismaClient();
    
    async function main() {
      const post = await prisma.post.create({
        data: {
          binary: Buffer.from([1, 2, 3]),
        },
      });
      console.log(post);
    }
    
    main()
      .catch((e) => {
        throw e;
      })
      .finally(async () => {
        await prisma.$disconnect();
      });
    { id: 'ckwpirbh80000qb8zgww1aa6y', binary: <Buffer 01 02 03> }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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