MongoDB: `Inconsistent column data: Failed to convert 'Decimal128(...)' to 'Decimal'.`
See original GitHub issueWhen you have a introspected schema with type Decimal
(E.g. via https://docs.atlas.mongodb.com/sample-data/sample-airbnb/), you get an error like this when you try to query for the data:
Error in Prisma Client request:
Invalid `prisma.listingsAndReviews.findMany()` invocation:
Inconsistent column data: Failed to convert 'Decimal128(...)' to 'Decimal'.
Schema:
generator client {
provider = "prisma-client-js"
previewFeatures = ["mongoDb"]
}
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
type ListingsAndReviewsAddress {
country String
country_code String
government_area String
location ListingsAndReviewsAddressLocation
market String
street String
suburb String
}
type ListingsAndReviewsAddressLocation {
coordinates Float[]
is_location_exact Boolean
type String
}
type ListingsAndReviewsAvailability {
availability_30 Int
availability_365 Int
availability_60 Int
availability_90 Int
}
type ListingsAndReviewsHost {
host_about String
host_has_profile_pic Boolean
host_id String
host_identity_verified Boolean
host_is_superhost Boolean
host_listings_count Int
host_location String
host_name String
host_neighbourhood String
host_picture_url String
host_response_rate Int?
host_response_time String?
host_thumbnail_url String
host_total_listings_count Int
host_url String
host_verifications String[]
}
type ListingsAndReviewsImages {
medium_url String
picture_url String
thumbnail_url String
xl_picture_url String
}
type ListingsAndReviewsReviewScores {
review_scores_accuracy Int?
review_scores_checkin Int?
review_scores_cleanliness Int?
review_scores_communication Int?
review_scores_location Int?
review_scores_rating Int?
review_scores_value Int?
}
type ListingsAndReviewsReviews {
id String @map("_id")
comments String?
date DateTime @db.Date
listing_id String
reviewer_id String
reviewer_name String
}
model listingsAndReviews {
id String @id @map("_id")
access String
accommodates Int
address ListingsAndReviewsAddress
amenities String[]
availability ListingsAndReviewsAvailability
bathrooms Decimal?
bed_type String
bedrooms Int?
beds Int?
calendar_last_scraped DateTime @db.Date
cancellation_policy String
cleaning_fee Decimal?
description String
extra_people Decimal
first_review DateTime? @db.Date
guests_included Decimal
host ListingsAndReviewsHost
house_rules String
images ListingsAndReviewsImages
interaction String
last_review DateTime? @db.Date
last_scraped DateTime @db.Date
listing_url String
maximum_nights String
minimum_nights String
monthly_price Json?
name String
neighborhood_overview String
notes String
number_of_reviews Int
price Decimal
property_type String
review_scores ListingsAndReviewsReviewScores
reviews ListingsAndReviewsReviews[]
reviews_per_month Int?
room_type String
security_deposit Decimal?
space String
summary String
transit String
weekly_price Decimal?
@@index([property_type, room_type, beds], map: "property_type_1_room_type_1_beds_1")
@@index([name], map: "name_1")
}
(Workaround of defining the field as Json
also does not work because of https://github.com/prisma/prisma/issues/12097)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:8 (6 by maintainers)
Top Results From Across the Web
inconsistent column data: failed to convert ... - You.com
With already existing data in a MongoDB, the prisma client fails to convert numeric strings into numbers and throws an error. Longer Description....
Read more >Unable to convert decimal to Decimal128 in python
What you seem to want to do is to convert a single decimal value in ... are often used as loop counter variables...
Read more >Functional Differences: Amazon DocumentDB and MongoDB
The following are the functional differences between Amazon DocumentDB (with MongoDB compatibility) and MongoDB. Topics. Functional Benefits of Amazon ...
Read more >Quick Start: BSON Data Types - Decimal128 - MongoDB
Working with decimal numbers can be a challenge. The Decimal128 BSON data type allows for high precision options when working with numbers.
Read more >Release Notes - Hackolade
... for incompatible data type change in Compare & Merge dialog - MongoDB ... and error details - Polyglot: added enforcement that only...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Introspection works fine, the
listingsAndReviews
above has manyDecimal
columns. But any interaction with them via the Query Engine leads to the reported error.sure, will do