Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WithQueryMode + update dependencies #129

Merged
merged 2 commits into from
Oct 2, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
version: v1.52.0
version: v1.60.3
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [ 1.21.x, 1.22.x ]
go-version: [ 1.21.x, 1.22.x, 1.23.x ]
os: [ ubuntu, windows, macOS ]
concurrency:
group: unit-${{ github.ref }}-${{ matrix.os }}-${{ matrix.go-version }}
Expand Down Expand Up @@ -38,8 +38,8 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.21.x, 1.22.x]
ydb-version: [23.3, 24.1]
go-version: [ 1.21.x, 1.22.x, 1.23.x ]
ydb-version: [23.3, 24.1, 24.2]
concurrency:
group: integration-${{ github.ref }}-${{ matrix.go-version }}-${{ matrix.ydb-version }}
cancel-in-progress: true
Expand Down
243 changes: 151 additions & 92 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# options for analysis running
run:
# default concurrency is a available CPU number
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 5m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1

Expand All @@ -16,13 +10,6 @@ run:
#build-tags:
# - mytag

# which dirs to skip: they won't be analyzed;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but next dirs are always skipped independently
# from this option's value:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
# skip-dirs:

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
Expand All @@ -35,7 +22,7 @@ run:
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
format: colored-line-number
formats: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true
Expand All @@ -56,26 +43,28 @@ linters-settings:
check-blank: false
govet:
# report about shadowed variables
check-shadowing: true
fieldalignment: true
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
shadow: true
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
gofumpt:
module-path: github.com/ydb-platform/gorm-driver
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/ydb-platform/gorm-driver
gci:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/ydb-platform/gorm-driver) # Custom section: groups all imports with the specified Prefix.
skip-generated: true
goconst:
# minimal length of string constant, 3 by default
min-len: 2
# minimal occurrences count to trigger, 3 by default
min-occurrences: 2
fieldalignment:
# print struct with more effective memory layout or not, false by default
suggest-new: true
ignore-tests: true
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
Expand Down Expand Up @@ -106,84 +95,149 @@ linters-settings:
- name: empty-block
- name: superfluous-else
- name: unreachable-code
unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
unparam:
# call graph construction algorithm (cha, rta). In general, use cha for libraries,
# and rta for programs with main packages. Default is cha.
algo: cha

# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false

gomoddirectives:
replace-local: true
replace-allow-list:
- xorm.io/xorm
gocritic:
disabled-checks:
- whyNoLint # https://github.com/go-critic/go-critic/issues/1063
- importShadow
- sloppyReassign
# - typeDefFirst
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
# See https://github.com/go-critic/go-critic#usage -> section "Tags".
# Default: []
enabled-tags:
- diagnostic
- style
- performance
- experimental
- opinionated
# Settings passed to gocritic.
# The settings key is the name of a supported gocritic checker.
# The list of supported checkers can be find in https://go-critic.github.io/overview.
settings:
# Must be valid enabled check name.
captLocal:
# Whether to restrict checker to params only.
# Default: true
paramsOnly: false
elseif:
# Whether to skip balanced if-else pairs.
# Default: true
skipBalanced: false
hugeParam:
# Size in bytes that makes the warning trigger.
# Default: 80
sizeThreshold: 70
nestingReduce:
# Min number of statements inside a branch to trigger a warning.
# Default: 5
bodyWidth: 4
rangeExprCopy:
# Size in bytes that makes the warning trigger.
# Default: 512
sizeThreshold: 516
# Whether to check test functions
# Default: true
skipTestFuncs: false
rangeValCopy:
# Size in bytes that makes the warning trigger.
# Default: 128
sizeThreshold: 32
# Whether to check test functions.
# Default: true
skipTestFuncs: false
ruleguard:
# Enable debug to identify which 'Where' condition was rejected.
# The value of the parameter is the name of a function in a ruleguard file.
#
# When a rule is evaluated:
# If:
# The Match() clause is accepted; and
# One of the conditions in the Where() clause is rejected,
# Then:
# ruleguard prints the specific Where() condition that was rejected.
#
# The flag is passed to the ruleguard 'debug-group' argument.
# Default: ""
debug: 'emptyDecl'
# Deprecated, use 'failOn' param.
# If set to true, identical to failOn='all', otherwise failOn=''
failOnError: false
# Determines the behavior when an error occurs while parsing ruleguard files.
# If flag is not set, log error and skip rule files that contain an error.
# If flag is set, the value must be a comma-separated list of error conditions.
# - 'all': fail on all errors.
# - 'import': ruleguard rule imports a package that cannot be found.
# - 'dsl': gorule file does not comply with the ruleguard DSL.
# Default: ""
failOn: dsl
# Comma-separated list of enabled groups or skip empty to enable everything.
# Tags can be defined with # character prefix.
# Default: "<all>"
enable: "myGroupName,#myTagName"
# Comma-separated list of disabled groups or skip empty to enable everything.
# Tags can be defined with # character prefix.
# Default: ""
disable: "myGroupName,#myTagName"
tooManyResultsChecker:
# Maximum number of results.
# Default: 5
maxResults: 10
truncateCmp:
# Whether to skip int/uint/uintptr types.
# Default: true
skipArchDependent: false
underef:
# Whether to skip (*x).method() calls where x is a pointer receiver.
# Default: true
skipRecvDeref: false
unnamedResult:
# Whether to check exported functions.
# Default: false
checkExported: true
linters:
disable-all: true
enable:
# - cyclop
enable-all: true
disable:
- contextcheck
- cyclop
- depguard
- dogsled
# - dupl
- errcheck
- errorlint
# - exhaustive
# - exhaustivestruct
# - forbidigo
# - funlen
# - gci
# - gocognit
- goconst
- dupl
- err113
- exhaustive
- exhaustruct
- fatcontext
- forbidigo
- gochecknoglobals
- gocognit
- gocritic
- gocyclo
# - godot
- godox
- gofmt # On why gofmt when goimports is enabled - https://github.com/golang/go/issues/21476
- gofumpt
- goheader
- goimports
# - gomnd
# - gomoddirectives
# - gomodguard
- godot
- gomnd
- gosec
- gosimple
- govet
- depguard
# - ifshort
# - ireturn
- lll
- makezero
- misspell
- ineffassign
- misspell
- nakedret
- nestif
# - nilnil
# - nlreturn
- nolintlint
- prealloc
- interfacebloat
- intrange
- ireturn
- maintidx
- mnd
- nonamedreturns
- paralleltest
- perfsprint
- predeclared
- rowserrcheck
- revive
- staticcheck
- stylecheck
# - tagliatelle
# - testpackage
# - thelper
# - tenv
- typecheck
- unconvert
- unparam
- unused
# - varnamelen
- whitespace
# - wrapcheck
# - wsl
- testableexamples
- testifylint
- testpackage
- thelper
- varnamelen
- wrapcheck
- wsl

issues:
# List of regexps of issue texts to exclude, empty list by default.
Expand All @@ -208,8 +262,10 @@ issues:
# Default value for this option is true.
exclude-use-default: true

# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-per-linter: 0
# Enables exclude of directories:
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
# Default: true
exclude-dirs-use-default: false

# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0
Expand All @@ -227,4 +283,7 @@ issues:

# Show only new issues created in git patch with set file path.
# new-from-patch: path/to/patch/file
# exclude-rules:
exclude-rules:
- linters:
- nosnakecase
text : "(?:_[a-z]+(?:[A-Z](?:[a-z\\d]+|[A-Z\\d]+))+|(?:[A-Z][a-z\\d]+|[A-Z][A-Z\\d]+)+_(?:(?:[A-Z][a-z\\d]+|[A-Z\\d][A-Z\\d]+)_?)+)"
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
* Upgraded dependencies:
* github.com/ydb-platform/ydb-go-sdk-auth-environ to v0.5.0
* github.com/ydb-platform/ydb-go-sdk/v3 to v3.81.4
* gorm.io/gorm to v1.25.12
* Added `WithQueryMode` context modifier and `QueryMode` constants

## v0.1.3
* Upgraded dependencies:
* github.com/golang-jwt/jwt/v4 v4.4.1 => v4.5.0
Expand Down
15 changes: 15 additions & 0 deletions driver.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ydb

import (
"context"
"time"

ydb "github.com/ydb-platform/ydb-go-sdk/v3"
Expand Down Expand Up @@ -31,6 +32,20 @@ func WithConnMaxIdleTime(d time.Duration) Option {
return dialect.WithConnMaxIdleTime(d)
}

type QueryMode = ydb.QueryMode

const (
DataQueryMode = ydb.DataQueryMode
ExplainQueryMode = ydb.ExplainQueryMode
ScanQueryMode = ydb.ScanQueryMode
SchemeQueryMode = ydb.SchemeQueryMode
ScriptingQueryMode = ydb.ScriptingQueryMode
)

func WithQueryMode(ctx context.Context, mode QueryMode) context.Context {
return ydb.WithQueryMode(ctx, mode)
}

func Open(dsn string, opts ...Option) gorm.Dialector {
return dialect.New(dsn, opts...)
}
Loading
Loading