Skip to content

TypedSQL define argument type as optional/nullable #6694

Open
@maciejopalinski

Description

@maciejopalinski

Your problem

https://www.prisma.io/docs/orm/prisma-client/using-raw-sql/typedsql#defining-argument-types-in-your-sql-files

TypedSQL allows to define argument types for SQL queries.

Currently accepted types are Int, BigInt, Float, Boolean, String, DateTime, Json, Bytes, and Decimal.

It does allow to define argument type as optional or nullable.

Suggested solution

It should be possible to define argument type as optional or nullable.
Here is my suggested example:

-- @param {String | null} $1:name The name of the user

and/or

-- @param {String?} $1:name The name of the user

Alternative solutions

Right now, I am using a pretty nasty workaround to be able to use optional argument types with TypedSQL queries.

const variable: string | null;

this.db.$queryRawTyped(myTypedSqlQuery(variable as string));

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    UnplanneddocsDocumentation creation, updates or corrections

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions