haskell-beam / haskell-beam/beam

Writing custom queries

Open
#620 2 comments 2 reactions 0 assignees View on GitHub
docs question
Dominant language
Haskell
Stars
635
Forks
193
PR merge metrics
No merged PRs in 30d

Description

I read these both pages:

1. https://hackage.haskell.org/package/beam-core-0.9.2.0/docs/Database-Beam-Query-CustomSQL.html
2. https://haskell-beam.github.io/beam/user-guide/extensibility/#custom-expressions

And have still no idea how to write a custom query. I followed the first page, which points to the non-existent page https://haskell-beam.github.io/beam/user-guide/extensibility/extensibility. Then I followed the second page and I end up getting errors:

```
• No instance for (IsCustomSqlSyntax
(Database.Beam.Backend.SQL.SQL92.Sql92SelectTableExpressionSyntax
(Database.Beam.Backend.SQL.SQL92.Sql92SelectSelectTableSyntax
(Database.Beam.Backend.SQL.SQL92.Sql92SelectSyntax
(Database.Beam.Backend.SQL.BeamSqlBackendSyntax ctxt)))))
arising from a use of ‘customExpr_’
• In the expression: customExpr_ myFuncImpl
In an equation for ‘instr_’:
instr_
= customExpr_ myFuncImpl
where
myFuncImpl :: (Monoid a, IsString a) => a -> a -> a
myFuncImpl str needle = "instr(" <> str <> ", " <> needle <> ")"
```

The page says:

> Your backend's syntax must implement the IsSqlCustomExpressionSyntax type class.

I don't know what that means. How to implement this? Where's an example?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.