You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whilst building a personal, side project I wanted to store an Array of Custom Codable Types.
struct CustomType: Codable {}
the resulting code in the tables' migration made use of the Custom option:
.array(of: .custom(CustomType.self))
All Vapor migrations ran like a charm but whilst testing it using Postman I ran into the following error:
Column custom_type is of type JSONB but expression is of type JSONB[]
Spent hours scouring the web for more info couldn't find any, banging my head against the wall trying to figure out what I was doing wrong with the JSON.
Finally, I reached out to Gwynne of the Vapor Core Team. She suggested swapping :
.array(of: .custom(CustomType.self))
for
.sql(raw: "JSONB[]")
Unsurprisingly, it worked!
Thank you for everything you do for the community.
The text was updated successfully, but these errors were encountered:
Hi,
Whilst building a personal, side project I wanted to store an Array of Custom Codable Types.
struct CustomType: Codable {}
the resulting code in the tables' migration made use of the Custom option:
.array(of: .custom(CustomType.self))
All Vapor migrations ran like a charm but whilst testing it using Postman I ran into the following error:
Spent hours scouring the web for more info couldn't find any, banging my head against the wall trying to figure out what I was doing wrong with the JSON.
Finally, I reached out to Gwynne of the Vapor Core Team. She suggested swapping :
.array(of: .custom(CustomType.self))
for
.sql(raw: "JSONB[]")
Unsurprisingly, it worked!
Thank you for everything you do for the community.
The text was updated successfully, but these errors were encountered: