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
14 changes: 7 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ name: Test

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
- name: Go linter
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v8
with:
version: v1.53
version: v2.1
- name: Run tests
run: go test -v ./...
44 changes: 20 additions & 24 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,54 @@
run:
skip-files:
- _test.go
version: "2"

linters:
enable-all: true
default: all
disable:
- maligned
- interfacer
- scopelint # deprecated
- golint # deprecated
- dupl
- funlen
- gomnd
- lll
- gochecknoglobals
- varnamelen
- ireturn
- gomoddirectives
- godox
- gocyclo
- exhaustivestruct
- exhaustruct
- tagliatelle
- wsl
# - wsl_v5
- forbidigo
- makezero
- depguard
- wrapcheck # will fix later
- wrapcheck
- gocritic # does not like log.Fatal with defers
- gci # collides with other linters
- godot # comments ending in periods...
- cyclop # like gocyclo
- gocognit # like cyclop
- maintidx # another complexity one
- goerr113 # wants static errors for all non-formatted error returns
- errname # base error naming
- nilnil # inconsistent error returns
- prealloc # wants to declaring vars with := struct{}
- ifshort # if blocks could be inlined
- nlreturn # wants newline before return, break, and continue (dont want newline before break & continue)
- exhaustive # some missing switch statements
- nestif # nested if blocks, complexity issues
- nestif # nested if blocks, complexity issues
- forcetypeassert # missing some checks, lots of false errors
- containedctx # some contexts embedded in structs
- contextcheck # probably worth looking at
- wastedassign # some interesting assignments, does not like declaring new vars like := ""
- promlinter # some observability stuff
- nonamedreturns
- nosnakecase # disbaled because of too many false positives due to protobuf types

linters-settings:
goheader:
values:
const:
COMPANY: Ctrl IQ, Inc
template: |-
SPDX-FileCopyrightText: Copyright (c) {{ YEAR-RANGE }}, {{ COMPANY }}. All rights reserved
SPDX-License-Identifier: Apache-2.0
settings:
goheader:
values:
const:
COMPANY: CTRL IQ, Inc
template: |-
SPDX-FileCopyrightText: Copyright (c) {{ YEAR-RANGE }}, {{ COMPANY }}. All rights reserved
SPDX-License-Identifier: Apache-2.0

exclusions:
warn-unused: false
paths:
- _test.go
- testproto/*
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module go.ciq.dev/pika

go 1.20
go 1.22

toolchain go1.24.4

require (
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df
Expand All @@ -13,7 +15,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
github.com/wk8/go-ordered-map/v2 v2.1.8
google.golang.org/protobuf v1.31.0
google.golang.org/protobuf v1.36.6
)

require (
Expand Down
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ github.com/gertd/go-pluralize v0.2.1 h1:M3uASbVjMnTsPb0PNqg+E/24Vwigyo/tvyMTtAlL
github.com/gertd/go-pluralize v0.2.1/go.mod h1:rbYaKDbsXxmRfr8uygAEKhOWsjyrrqrkHVpZvoOp8zk=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g=
Expand Down Expand Up @@ -43,15 +42,14 @@ github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+x
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU=
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
8 changes: 5 additions & 3 deletions parser/gen.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2023-2024, Ctrl IQ, Inc. All rights reserved
// SPDX-FileCopyrightText: Copyright (c) 2023-2025, CTRL IQ, Inc. All rights reserved
// SPDX-License-Identifier: Apache-2.0

package parser
//go:generate antlr -Dlanguage=Go -o . Filter.g4

//go:generate antlr4 -Dlanguage=Go -no-visitor -package parser Filter.g4
// Package parser provides ANTLR-generated parsers for filter expressions.
// This package contains generated code for parsing AIP-160 compliant filter syntax.
package parser
14 changes: 11 additions & 3 deletions pika.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright (c) 2023-2024, Ctrl IQ, Inc. All rights reserved
// SPDX-FileCopyrightText: Copyright (c) 2023-2025, CTRL IQ, Inc. All rights reserved
// SPDX-License-Identifier: Apache-2.0

package pika
Expand All @@ -10,14 +10,20 @@ import (
)

var (
PikaMetadataTableName = "PikaTableName"
// PikaMetadataTableName is the field name used to specify custom table names in struct tags.
PikaMetadataTableName = "PikaTableName"
// PikaMetadataDefaultOrderBy is the field name used to specify default ordering in struct tags.
PikaMetadataDefaultOrderBy = "PikaDefaultOrderBy"
PikaMetadataFields = []string{
// PikaMetadataFields contains all available metadata field names for Pika configuration.
PikaMetadataFields = []string{
PikaMetadataTableName,
PikaMetadataDefaultOrderBy,
}
)

// Q creates a new QuerySet for the given type T using the provided database connection.
// It automatically detects the database type and returns the appropriate QuerySet implementation.
// Currently supports PostgreSQL connections. Panics if an unsupported database type is provided.
func Q[T any](x any) QuerySet[T] {
if sql, ok := x.(*PostgreSQL); ok {
return PSQLQuery[T](sql)
Expand Down Expand Up @@ -199,6 +205,8 @@ type QuerySet[T any] interface {
Transaction(ctx context.Context) (QuerySet[T], error)
}

// NewArgs creates a new ordered map for storing named query arguments.
// This is a convenience function for creating argument maps that can be passed to QuerySet.Args().
func NewArgs() *orderedmap.OrderedMap[string, any] {
return orderedmap.New[string, any]()
}
Loading