Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
/cql-cli
/pgcql-cli
.vscode
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,35 @@ func main() {

See the [cql-cli source](cmd/cql-cli/main.go) for a more complete example.

## Building CQL programmatically

If you want to construct valid CQL queries without hand-assembling the AST, use the
fluent builder in `cqlbuilder` which validates inputs and escapes terms.

```go
import (
"fmt"

"github.com/indexdata/cql-go/cql"
"github.com/indexdata/cql-go/cqlbuilder"
)
Comment on lines +39 to +44
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import statement is missing the "os" package, which is required for the os.Stderr reference in the example code at line 55. This will cause a compilation error if someone tries to use this example.

Copilot uses AI. Check for mistakes.

func main() {
query, err := cqlbuilder.NewQuery().
Prefix("dc", "http://purl.org/dc/elements/1.1/").
Search("dc.title").
Rel(cql.EQ).
Term("the \"little\" prince").
SortBy("dc.title", cql.IgnoreCase).
Build()
if err != nil {
fmt.Fprintln(os.Stderr, "ERROR", err)
return
}
fmt.Println(query.String())
}
```

## Conformance

The CQL specification requires that a query consist of a single search term with an optional index and relation:
Expand Down
Loading