hope you help me with this.
i have a rawSql:
latestPrice :: Handler [(Single PricesId, Single PersistValue, Single PersistValue, Single PersistValue, Single PersistValue, Single PersistValue)]
latestPrice = do
runDB $ rawSql qryStr []
where qryStr = " SELECT prices.id,\
\CONCAT(cities.name, '(', states.code, '), ', countries.name) as city, \
\prices.s_id, \
\prices.s_name, \
\prices.quality, \
\AVG(prices.amount) as amount \
\FROM prices \
\INNER JOIN cities ON cities.id = prices.city_id \
\INNER JOIN states ON states.id = cities.state_id \
\INNER JOIN countries ON countries.id = states.country_id \
\WHERE prices.city_id > 0 \
\GROUP BY prices.id, city, prices.strain_id, prices.strain_name, prices.quality, prices.quality;";
and i have a handler that call that function and should return a JSON Format:
getLatestPriceSubmissionR:: Handler (Value)
getLatestPriceSubmissionR = do
results <- latestPrice
return map (
\(Single id, Single city, Single s_name, Single strain_id, Single quality, Single amount) -> [ "id" .= id,"city" .= city,"s_id" .= s_id,"s_name" .= s_name, "quality" .= quality,"amount" .= amount ]
) results
my question is:
does my code in Handler getLatestPriceSubmissionR
is correct?
it does give me only a warning message not an error message:
Couldn't match type [[aeson-0.8.0.0:Data.Aeson.Types.Internal.Pair]]
with Value
Expected type: HandlerT App IO Value
Actual type: HandlerT
App IO [[aeson-0.8.0.0:Data.Aeson.Types.Internal.Pair]] …
also
No instance for (ToTypedContent [Value])
arising from a use of yesodRunner
Hope you help me.
thank you in advance