"Looking at slick-pg's code, I noticed that PlayJsonImplicits didn't define a GetResult[JsValue], but PlayJsonPlainImplicits did. I mixed PlayJsonPlainImplicits into my profile, and the compile issue disappeared. So far, so good. One point for human intelligence, and one for AI for nudging me toward the right area."
"That might compile. But it also looked suspicious. My original query returned a SqlStreamingAction. This suggestion used `.map` on the action result, which appeared to operate on the full materialized result set. In other words, it seemed to 'fix' the type issue by changing the execution model by performing an extra full pass over the result set."
A developer encountered compile errors using Scala Slick with plain SQL queries returning complex tuples including JsValue and Instant types. Initial AI suggestions proved unhelpful until identifying that slick-pg's PlayJsonImplicits lacked GetResult[JsValue] for plain SQL, while PlayJsonPlainImplicits provided it. Mixing the latter into the profile resolved the JsValue issue. For Instant fields, ChatGPT suggested decoding as java.sql.Timestamp then converting to Instant using .map on the action result. However, this approach appeared problematic as it would materialize the entire result set before conversion, potentially degrading performance compared to handling conversion at the database level.
#scala-slick #getresult-implicits #ai-debugging-limitations #performance-optimization #plain-sql-queries
Read at Medium
Unable to calculate read time
Collection
[
|
...
]