This is great, full support for native types has been added in prisma/prisma@v2.15.0!

For example, setting price with two decimal places:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["nativeTypes"]
}
model Product {
  name   String
  price  Decimal?  @mysql.Decimal(10, 2)
}

Note that this would now return a Decimal (not native number):

const product = prisma.product.findFirst();
const price = product.price; // This is a `Decimal`, so you should typecast it
const discountedPrice = product.price.toNumber() * 0.9;
🌐
YouTube
youtube.com › prisma
Changes to the default mapping of Float in Prisma 2.17.0 - YouTube
In previous versions of Prisma, the Float type in the Prisma schema would map to the Decimal type in MySQL and PostgreSQL. Version 2.17 of Prisma brings two ...
Published   February 16, 2021
Views   3K
Discussions

@db.Decimal in Prisma ("s", "e", "d")
I fixed my result set using ... number type. But I'm thinking if it's interesting to run a system-wide workaround like this: github.com/prisma/prisma/issues/6049#issuecomment-1837616160 ... Save this answer. ... Show activity on this post. You could just use Float instead (which ... More on stackoverflow.com
🌐 stackoverflow.com
How to use DECIMAL(10,2) in prisma migrate tool? - Stack Overflow
I need save DECIMAL(10,2) in database. In MySQL there is DECIMAL type. ... I am using Prisma Migrate flow and see that mapping is constrained. More on stackoverflow.com
🌐 stackoverflow.com
Inserting Float type requires a decimal value (different from 0)
(node:9911) UnhandledPromiseRe...xecute::h992b6a51be508cce (0x1041b7a9b) 13: core::executor::Executor::exec_all::h5cbc538ae21b3c80 (0x1041d6be4) 14: ::handle::h7d76032243e11158 ... More on github.com
🌐 github.com
3
July 21, 2019
Error for Float type (postgresql)
Replacing the Float type with an Int type gets rid of the error. This is with prisma2@0.0.114 and local postgresql (docker). More on github.com
🌐 github.com
3
July 7, 2019
🌐
GitHub
github.com › prisma › prisma › issues › 17894
Prisma loss of precision on float values · Issue #17894 · prisma/prisma
February 11, 2023 - bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.tech/engines/query engineIssue in the Query EngineIssue in the Query Enginetopic: floating point typesTopic related to floating point types and precision lossTopic related to floating point types and precision losstopic: mysql ... Possibly related to this ticket. Seems like the issue is back. #3479 · Tested on 4.10.1 and 4.8.0. I was able to replicate it consistently by starting from a number such as 531.8 (notice singular decimal precision) and decrementing 26.11 which gives me the unfortunate 505.6899999999999. To decrement I used prisma's decrement API.
Author   prisma
🌐
Prisma
prisma.io › home › how to use prisma orm's type system › how to use prisma orm's type system › how to use prisma orm's type system › how to use prisma orm's type system
How to use Prisma ORM's type system | Prisma Documentation
For example, this table gives the default type mappings for PostgreSQL. To see the default type mappings for all databases for a specific given Prisma ORM type, see the model field scalar types section of the Prisma schema reference. For example, this table gives the default type mappings for the Float scalar type.
🌐
Readthedocs
prismadb.readthedocs.io › en › latest › data-types
Data Types - Prisma/DB Documentation
Skip to content · Data Types · MySQL · SQL Server · length values for SQL Server datatypes can also be defined as MAX · PostgreSQL
🌐
Prisma
prisma.io › dataguide › mysql › introduction-to-data-types
MySQL data types | Introduction | Prisma's Data Guide
Both floating point numbers provided by types like FLOAT and DOUBLE and fixed point numbers provided by the NUMERIC or DECIMAL types can be used to store decimal values.
🌐
Prisma
prisma.io › home › schema api › schema api › schema api
Prisma Schema API | Prisma Documentation
You can use Prisma Migrate to map @db.Bit(1) to String: model Model { /* ... */ myField String @db.Bit(1) } String · TEXT · Note that the xml and citext types supported in PostgreSQL are not currently supported in CockroachDB. True or false value. Bool · INTEGER · Int · INTEGER · Long · INTEGER · Floating point number.
Find elsewhere
🌐
Wanago
wanago.io › home › api with nestjs #147. the data types to store money with postgresql and prisma
API with NestJS #147. The data types to store money with PostgreSQL and Prisma
March 4, 2024 - A valid solution to storing money is to use integers instead of floats. The crucial thing about this approach is that we need to represent all money values in the smallest currency unit, such as cents. Instead of storing $15.20, we would store 1520 cents. When performing various calculations, we need to remember that all values are in the smallest unit. After creating the migration, we can see the following SQL: We can see that Prisma generated a migration that uses the INTEGER data type.
🌐
Prisma
prisma.io › dataguide › postgresql › introduction-to-data-types
PostgreSQL Data Types - Numeric, Text, and More - Prisma
In contrast, types like float and double precision are variable precision types. The amount of precision they maintain depends on the input value.
🌐
GitHub
github.com › prisma › prisma › issues › 198
Inserting Float type requires a decimal value (different from 0) · Issue #198 · prisma/prisma
July 21, 2019 - prisma / prisma Public · Notifications ... · New issueCopy link · Closed · Closed · Inserting Float type requires a decimal value (different from 0)#198 ·...
Author   prisma
🌐
Prisma
prisma.io › docs › concepts › components › preview-features › native-types › native-types-mappings
Type mapping reference (Reference) | Prisma Documentation
The following table lists the MySQL native database types that map to Prisma's Decimal scalar type: Floating point number.
🌐
Prisma
prisma.io › home › fields & types › fields & types › fields & types
Fields & types | Prisma Documentation
This section covers various special fields and types you can use with Prisma Client.
🌐
StudyRaid
app.studyraid.com › en › read › 11147 › 345636 › data-types-and-attributes
Data Types and Attributes - Building and Managing ...
Prisma provides a set of built-in scalar types that map to the native data types of the underlying database. These types include: String: Represents text data. Int: Represents integer values. Float: Represents floating-point numbers.
🌐
GitHub
github.com › prisma › prisma › issues › 147
Error for Float type (postgresql) · Issue #147 · prisma/prisma
July 7, 2019 - Replacing the Float type with an Int type gets rid of the error. This is with prisma2@0.0.114 and local postgresql (docker).
Author   prisma