Skip to content

valkey not working: No instance for (ToBackendKey SqlBackend Product) #161

@MuhammedZakir

Description

@MuhammedZakir

Schema:

share [ mkPersist sqlSettings
      , mkMigrate "migrateAll" ] [persistUpperCase|
Product
  Id    Int
  name  Text
  deriving Eq Show
]

Helper functions:

dbName = "/tmp/esqueleto.db"

connectionPool = do
  conInfo <- walEnabled (const $ pure False) $ mkSqliteConnectionInfo dbName
  runStdoutLoggingT $ createSqlitePoolFromInfo conInfo 1

pool = connectionPool

q q = pool >>= \p -> runSqlPool q p

For above schema, running this in ghci

q $ select $ (from $ table @Product) >>= \ps -> where_ (ps ^. ProductId ==. valkey 1) >> pure ps

throws

• No instance for (ToBackendKey SqlBackend Product)
        arising from a use of ‘valkey’

<context info>

This works:

q $ select $ (from $ table @Product) >>= \ps -> where_ (ps ^. ProductId ==. (val $ ProductKey 1)) >> pure ps

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions