Skip to content

Commit

Permalink
Merge pull request #396 from k1LoW/pkg-update
Browse files Browse the repository at this point in the history
Update pkgs
  • Loading branch information
k1LoW committed Dec 11, 2022
2 parents 73c7c2e + f6bea40 commit 8ffa1a1
Show file tree
Hide file tree
Showing 6 changed files with 366 additions and 680 deletions.
9 changes: 8 additions & 1 deletion datasource/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ func Analyze(dsn config.DSN) (*schema.Schema, error) {
}

opts := []drivers.Option{}
if u.Driver == "mysql" {
switch u.Driver {
case "mysql":
values := u.Query()
for k := range values {
if k == "show_auto_increment" {
Expand All @@ -70,6 +71,12 @@ func Analyze(dsn config.DSN) (*schema.Schema, error) {
}
u.RawQuery = values.Encode()
urlstr = u.String()
case "sqlserver":
values := u.Query()
dbname := strings.TrimPrefix(u.Path, "/")
values.Add("database", dbname)
u.RawQuery = values.Encode()
urlstr = u.String()
}

db, err := dburl.Open(urlstr)
Expand Down
2 changes: 1 addition & 1 deletion datasource/datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"path/filepath"
"testing"

_ "github.com/denisenkom/go-mssqldb"
_ "github.com/go-sql-driver/mysql"
"github.com/k1LoW/tbls/config"
_ "github.com/lib/pq"
_ "github.com/microsoft/go-mssqldb"
)

var tests = []struct {
Expand Down
23 changes: 15 additions & 8 deletions drivers/mssql/mssql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,43 @@ package mssql

import (
"database/sql"
"os"
"log"
"testing"

_ "github.com/denisenkom/go-mssqldb"
"github.com/k1LoW/tbls/schema"
_ "github.com/microsoft/go-mssqldb"
"github.com/xo/dburl"
)

var s *schema.Schema
var db *sql.DB
var err error

func TestMain(m *testing.M) {
s = &schema.Schema{
Name: "testdb",
}
db, _ = dburl.Open("ms://SA:MSSQLServer-Passw0rd@localhost:11433/testdb")
db, err = dburl.Open("ms://SA:MSSQLServer-Passw0rd@localhost:11433/instance?database=testdb")
if err != nil {
log.Fatal(err)
}
defer db.Close()
exit := m.Run()
if exit != 0 {
os.Exit(exit)
if err := db.Ping(); err != nil {
log.Fatal(err)
}
_ = m.Run()
}

func TestAnalyzeView(t *testing.T) {
driver := New(db)
err := driver.Analyze(s)
if err != nil {
t.Errorf("%v", err)
t.Error(err)
}
view, err := s.FindTableByName("post_comments")
if err != nil {
t.Fatal(err)
}
view, _ := s.FindTableByName("post_comments")
want := view.Def
if want == "" {
t.Errorf("got not empty string.")
Expand Down
152 changes: 85 additions & 67 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,98 +3,116 @@ module github.com/k1LoW/tbls
go 1.18

require (
cloud.google.com/go/bigquery v1.25.0
cloud.google.com/go/spanner v1.28.0
cloud.google.com/go/bigquery v1.44.0
cloud.google.com/go/spanner v1.41.0
github.com/antonmedv/expr v1.9.0
github.com/aquasecurity/go-version v0.0.0-20210121072130-637058cfe492
github.com/aws/aws-sdk-go v1.42.23
github.com/aws/aws-sdk-go v1.44.157
github.com/beta/freetype v0.0.1
github.com/denisenkom/go-mssqldb v0.11.0
github.com/gertd/go-pluralize v0.1.7
github.com/go-sql-driver/mysql v1.6.0
github.com/gertd/go-pluralize v0.2.1
github.com/go-sql-driver/mysql v1.7.0
github.com/goccy/go-graphviz v0.0.9
github.com/goccy/go-yaml v1.9.4
github.com/google/go-cmp v0.5.8
github.com/k1LoW/duration v1.1.0
github.com/k1LoW/expand v0.1.0
github.com/goccy/go-yaml v1.9.7
github.com/google/go-cmp v0.5.9
github.com/k1LoW/duration v1.2.0
github.com/k1LoW/expand v0.5.5
github.com/k1LoW/ffff v0.2.0
github.com/labstack/gommon v0.3.1
github.com/lib/pq v1.10.4
github.com/labstack/gommon v0.4.0
github.com/lib/pq v1.10.7
github.com/loadoff/excl v0.0.0-20171207172601-c6a9e4c4b4c4
github.com/mattn/go-runewidth v0.0.13
github.com/mattn/go-sqlite3 v1.14.9
github.com/minio/pkg v1.1.9
github.com/mattn/go-runewidth v0.0.14
github.com/mattn/go-sqlite3 v1.14.16
github.com/microsoft/go-mssqldb v0.18.0
github.com/minio/pkg v1.5.6
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0
github.com/snowflakedb/gosnowflake v1.6.5
github.com/spf13/cobra v1.3.0
github.com/xo/dburl v0.9.0
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
github.com/snowflakedb/gosnowflake v1.6.15
github.com/spf13/cobra v1.6.1
github.com/xo/dburl v0.13.0
gitlab.com/golang-commonmark/mdurl v0.0.0-20191124015652-932350d1cb84
go.mongodb.org/mongo-driver v1.8.4
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2
google.golang.org/api v0.86.0
go.mongodb.org/mongo-driver v1.11.1
golang.org/x/image v0.2.0
golang.org/x/oauth2 v0.3.0
google.golang.org/api v0.104.0
)

require (
cloud.google.com/go v0.102.0 // indirect
cloud.google.com/go/compute v1.7.0 // indirect
cloud.google.com/go/iam v0.3.0 // indirect
cloud.google.com/go v0.107.0 // indirect
cloud.google.com/go/compute v1.14.0 // indirect
cloud.google.com/go/compute/metadata v0.2.2 // indirect
cloud.google.com/go/iam v0.8.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/Azure/azure-pipeline-go v0.2.3 // indirect
github.com/Azure/azure-storage-blob-go v0.14.0 // indirect
github.com/Azure/azure-storage-blob-go v0.15.0 // indirect
github.com/apache/arrow/go/arrow v0.0.0-20211112161151-bc219186db40 // indirect
github.com/aws/aws-sdk-go-v2 v1.11.2 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.0.0 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.6.4 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.7.4 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.2 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.0.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.5.0 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.5.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.9.2 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.21.0 // indirect
github.com/aws/smithy-go v1.9.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.17.2 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.4 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.43 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.26 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.20 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.17 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.21 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.20 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.20 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.29.5 // indirect
github.com/aws/smithy-go v1.13.5 // indirect
github.com/buildkite/interpolate v0.0.0-20200526001904-07f35b4ae251 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe // indirect
github.com/cncf/xds/go v0.0.0-20221128185840-c261a164b73d // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
github.com/envoyproxy/go-control-plane v0.10.3 // indirect
github.com/envoyproxy/protoc-gen-validate v0.9.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fogleman/gg v1.3.0 // indirect
github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect
github.com/gabriel-vasile/mimetype v1.4.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
github.com/gabriel-vasile/mimetype v1.4.1 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/flatbuffers v2.0.5+incompatible // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/flatbuffers v22.11.23+incompatible // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/k1LoW/fontdir v0.1.1 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-ieproxy v0.0.1 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/pierrec/lz4/v4 v4.1.12 // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-ieproxy v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/montanaflynn/stats v0.6.6 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/sahilm/fuzzy v0.1.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.0.2 // indirect
github.com/xdg-go/stringprep v1.0.2 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b // indirect
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
golang.org/x/sys v0.0.0-20220624220833-87e55d714810 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.4.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/term v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
google.golang.org/grpc v1.51.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)
Loading

0 comments on commit 8ffa1a1

Please sign in to comment.