Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: can't cast to JSON::Any #263

Open
ejstembler opened this issue Jan 15, 2023 · 0 comments
Open

Error: can't cast to JSON::Any #263

ejstembler opened this issue Jan 15, 2023 · 0 comments

Comments

@ejstembler
Copy link

I originally opened an issue on crystal-db, though Brian pointed out a change here. I've read though the change, however, I'm still not clear how to update my code to accomodate the new strategy.


I'm upgrading from Crystal 1.5.0, crystal-db 0.10.0, crystal-pg 0.23.1 and I'm seeing this error:

Error: can't cast (Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | Bool | Char | Float32 | Float64 | Int16 | Int32 | Int64 | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt32 | UUID | Nil) to JSON::Any

from:

db.scalar(sql).as(JSON::Any)

In Postgres I have a function which RETURNS jsonb. JSON::Any worked fine for me before. I don't want to cast the JSON to a serializable class because the JSON is too verbose with nested data.

Any tips on what I need to change to keep the JSON::Any output? Or, is that a lost cause?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant