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
@@ -0,0 +1 @@
.idea
6 changes: 3 additions & 3 deletions cli/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"context"
"database/sql"
"errors"
"fmt"
mssql "github.com/denisenkom/go-mssqldb"
"github.com/denisenkom/go-mssqldb/azuread"
Expand All @@ -14,7 +15,6 @@ import (

_ "github.com/denisenkom/go-mssqldb/azuread"
"github.com/denisenkom/go-mssqldb/msdsn"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -48,7 +48,7 @@ func OpenSocks5Sql(dsn string) (*sql.DB, error) {
if socksProxyAddress != "" {
dialer, err := proxy.SOCKS5("tcp", socksProxyAddress, nil, nil)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("Could not connect with SOCKS5 to %s", socksProxyAddress))
return nil, fmt.Errorf("could not connect with SOCKS5 to %s because of: %w", socksProxyAddress, err)
}
connector.Dialer = dialer.(proxy.ContextDialer)
}
Expand All @@ -70,7 +70,7 @@ func LoadConfig() (Config, error) {

configFilename := path.Join(directory, "sqlcode.yaml")
if _, err := os.Stat(configFilename); os.IsNotExist(err) {
return Config{}, errors.New("No sqlcode.yaml found in current directory")
return Config{}, errors.New("no sqlcode.yaml found in current directory")
}

yamlFile, err := ioutil.ReadFile(configFilename)
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/constants.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cmd

import (
"errors"
"fmt"

"github.com/pkg/errors"
"github.com/spf13/cobra"
)

Expand All @@ -14,7 +14,7 @@ var (
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 0 {
_ = cmd.Help()
return errors.New("Too many arguments")
return errors.New("too many arguments")
}
d, err := dep(true)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/dep.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package cmd

import (
"errors"
"fmt"
"os"

"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/vippsas/sqlcode"
)
Expand All @@ -27,7 +27,7 @@ var (
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 0 {
_ = cmd.Help()
return errors.New("Too many arguments")
return errors.New("too many arguments")
}
d, err := dep(true)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions deployable.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package sqlcode
import (
"context"
"database/sql"
"errors"
"fmt"
"io/fs"
"strconv"
"strings"
"time"

mssql "github.com/denisenkom/go-mssqldb"
"github.com/pkg/errors"
"github.com/vippsas/sqlcode/sqlparser"
)

Expand Down Expand Up @@ -220,7 +220,7 @@ func (d Deployable) IntConst(s string) (int, error) {
return strconv.Atoi(declare.Literal.RawValue)
}
}
return 0, errors.New("No `declare `" + s + "` found")
return 0, fmt.Errorf("no `declare %s found`", s)
}

func (d Deployable) MustIntConst(s string) int {
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module github.com/vippsas/sqlcode

go 1.23.7
go 1.24.3

require (
github.com/alecthomas/repr v0.4.0
github.com/denisenkom/go-mssqldb v0.12.3
github.com/gofrs/uuid v4.4.0+incompatible
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
github.com/smasher164/xid v0.1.2
github.com/spf13/cobra v1.9.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3P
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down
2 changes: 1 addition & 1 deletion preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package sqlcode
import (
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"github.com/pkg/errors"
"github.com/vippsas/sqlcode/sqlparser"
"regexp"
"strings"
Expand Down
15 changes: 7 additions & 8 deletions sqltest/querydump.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"time"

"github.com/alecthomas/repr"
"github.com/pkg/errors"
)

type MapRow map[string]interface{}
Expand All @@ -24,7 +23,7 @@ func runQuery(dbi interface{}, qry string, args ...interface{}) *sql.Rows {
case CtxQuerier:
rows, err := q.QueryContext(context.Background(), qry, args...)
if err != nil {
panic(errors.WithStack(err))
panic(fmt.Sprintf("runQuery, query: %s \n\n arguments:%+v \n\n error: %s", qry, args, err))
}
return rows
default:
Expand All @@ -38,11 +37,11 @@ func RowIteratorToSlice(rows *sql.Rows) (columns []string, result Rows) {

columns, err := rows.Columns()
if err != nil {
panic(errors.WithStack(err))
panic(fmt.Sprintf("RowIteratorToSlice: while getting columns: %s", err))
}
types, err := rows.ColumnTypes()
if err != nil || len(types) != len(columns) {
panic(errors.WithStack(err))
panic(fmt.Sprintf("RowIteratorToSlice: while getting columns types: %s", err))
}
n := len(columns)
rowValues := make([]interface{}, n, n)
Expand All @@ -53,7 +52,7 @@ func RowIteratorToSlice(rows *sql.Rows) (columns []string, result Rows) {
for rows.Next() {
err = rows.Scan(pointers...)
if err != nil {
panic(errors.WithStack(err))
panic(fmt.Sprintf("RowIteratorToSlice: while scanning: %s", err))
}

var row Row
Expand Down Expand Up @@ -130,21 +129,21 @@ func Query(dbi CtxQuerier, qry string, args ...interface{}) Rows {

func QueryInt(dbi CtxQuerier, qry string, args ...interface{}) (result int) {
if err := dbi.QueryRowContext(context.Background(), qry, args...).Scan(&result); err != nil {
panic(errors.WithStack(err))
panic(fmt.Sprintf("QueryInt, query: %s\n\n arguments:%+v\n\n error: %s", qry, args, err))
}
return
}

func QueryString(dbi CtxQuerier, qry string, args ...interface{}) (result string) {
if err := dbi.QueryRowContext(context.Background(), qry, args...).Scan(&result); err != nil {
panic(errors.WithStack(err))
panic(fmt.Sprintf("QueryString, query: %s\n\n arguments:%+v\n\n error: %s", qry, args, err))
}
return
}

func QueryTime(dbi CtxQuerier, qry string, args ...interface{}) (result time.Time) {
if err := dbi.QueryRowContext(context.Background(), qry, args...).Scan(&result); err != nil {
panic(errors.WithStack(err))
panic(fmt.Sprintf("QueryTime, query: %s\n\n arguments:%+v\n\n error: %s", qry, args, err))
}
return
}
Expand Down