3 ms·
Won't the functional variant read better than the SQL dialect movie_reviews .filter(_.actor.name.lowercase() == "Zendaya") .groupBy(_.title, _.credit_o
by nikhilsimha 5y ago
Won't the functional variant read better than the SQL dialect
movie_reviews
.filter(_.actor.name.lowercase() == "Zendaya")
.groupBy(_.title, _.credit_order, avg(_.ratings))
.sortBy(_.credit_order)
.take(5)
vs.
select
Movie {
title,
rating := math::mean(.ratings.score)
actors: {
name
} order by @credits_order
limit 5,
}
filter
"Zendaya" in .actors.name
- RedCrowbar 5y agoIt's a matter of taste. We decided to do a "looks like SQL + GraphQL" style because that's what most people are familiar when they think about a query language. That said, the functional variant is a likely way to represent EdgeQL in programming languages.
- 1st1 5y agoKeep in mind that EdgeQL is a query language that can be used from any programming language (either over the official libraries, or over HTTP). Functional JS-inspired dialects aren't appealing to everybody.
- udfalkso 5y agoI like the flow of yours, but it doesn't capture the GraphQL piece. Where do you specify the nested limit and desired fields for the inner "actors"?
- cakoose 5y agoYour query returns 5 rows total. The EdgeDB query returns all movies that Zendaya is in [1] and, along with each movie, the first 5 credited actors. Also, it looks like your version also does implicit joins (like EdgeDB), but I'm not sure how they would work in that style. [1] Or maybe only movies where Zendaya is in the first 5 credited actors; I'm not sure.