Reputation: 641
This morning I started setting up Esqueleto in a Yesod app. I'm really trying to do a LeftOuterJoin, but I've simplified the query down quite a bit in order to get the basics working. I can't even get that. To be sure there are no conflicts with Database.Persist.Query, I've followed some advice from a Github issue to extract my query into separate file that doesn't import Yesod. Is there something I'm missing in configuring Esqueleto?
FWIW, I'm using Yesod 1.4.0, Persistent 2.1 & Esqueleto 2.1.
This is the error I'm experiencing:
Queries.hs:9:15:
No instance for (Database.Esqueleto.Internal.Sql.SqlSelect
(SqlExpr (Entity UrlEntry), SqlExpr (Entity UrlEntryData))
(Entity UrlEntry))
arising from a use of ‘select’
In the expression: select
In the expression:
select
$ from
$ \ (entry `InnerJoin` entryData)
-> do { on
$ entry ^. UrlEntryId ==. entryData ^. UrlEntryDataUrlEntryId;
return (entry, entryData) }
In an equation for ‘findEntries’:
findEntries
= select
$ from
$ \ (entry `InnerJoin` entryData)
-> do { on
$ entry ^. UrlEntryId ==. entryData ^. UrlEntryDataUrlEntryId;
.... }
Here are my models:
UrlEntry
url String
shortCode String
ShortCode shortCode
visits Int default=0
userId UserId Eq
deriving Eq Show
UrlEntryData
screenshot String Maybe
title String Maybe
favicon String Maybe
contentType String
urlEntryId UrlEntryId Eq
deriving Eq Show
User
email Text
password Text Maybe
verkey Text Maybe
verified Bool
UniqueUser email
deriving Eq Show Typeable
And here is my query:
findEntries :: SqlPersistT Handler [Entity UrlEntry]
findEntries = select $ from $ \(entry `InnerJoin` entryData) -> do
on $ entry ^. UrlEntryId ==. entryData ^. UrlEntryDataUrlEntryId
-- where_ (entry ?. UrlEntryUserId ==. valkey authId)
return (entry, entryData)
Upvotes: 2
Views: 205
Reputation: 1942
You need to change function signature.
findEntries :: SqlPersistT Handler [(Entity UrlEntry, Entity UrlEntryData)]
Upvotes: 1