Skip to content

Commit

Permalink
Merge pull request #15 from RyougiNevermore/master
Browse files Browse the repository at this point in the history
update cmd to v2
  • Loading branch information
RyougiNevermore committed Jul 22, 2020
2 parents 8f588a7 + f0f06a0 commit 6ec8203
Show file tree
Hide file tree
Showing 38 changed files with 52 additions and 151 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ tx.Commit()
```
## Code Generates
### Install dalc
`go get -u github.com/pharosnet/dalc/cmd/dalc`
`go get -u github.com/pharosnet/dalc/cmd/dalc/v2`
### Write sql schema files
Write sql schema files in some folder, such as schema/, and foo.sql in this folder.
```sql
Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/pharosnet/dalc/cmd/dalc
module github.com/pharosnet/dalc/cmd/dalc/v2

go 1.14

Expand Down
93 changes: 0 additions & 93 deletions cmd/dalc/internal/config/config.go

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/dalc/internal/entry/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package entry

import (
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/commons"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/commons"
"strings"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/generates/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package generates

import (
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/logs"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/logs"
"go/format"
"io/ioutil"
"os"
Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/generates/generate.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package generates

import (
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"path/filepath"
)

Expand Down
8 changes: 4 additions & 4 deletions cmd/dalc/internal/generates/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package generates
import (
"bytes"
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/commons"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/commons"
"strings"
"text/template"
)
Expand Down Expand Up @@ -163,7 +163,7 @@ type {{ .Name }}Request struct { {{ range $key, $field := .RequestFields}}
}
{{ if eq .IsTable true }}
type {{ .Name }}ResultIterator func(ctx context.Context, result *{{ .Table.GoName }}) (err error)
type {{ .Name }}ResultIterator func(ctx context.Context, result *{{ .Table.GoName }}Row) (err error)
{{ else }}
type {{ .Name }}Result struct { {{ range $key, $field := .ResultFields}}
{{ $field.Name }} {{ $field.Type }} {{ $field.Tags }}{{ end }}
Expand All @@ -189,7 +189,7 @@ func {{ .Name }}(ctx dalc.PreparedContext, request *{{ .Name }}Request, iterator
}
{{ if eq .IsTable true }}
result := &{{ .Table.GoName }}{}
result := &{{ .Table.GoName }}Row{}
scanErr := result.scanSQLRow(rows)
{{ else }}
result := &{{ .Name }}Result{}
Expand Down
4 changes: 2 additions & 2 deletions cmd/dalc/internal/generates/query_select.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type {{ .Name }}Request struct { {{ range $key, $field := .RequestFields}}
}

{{ if eq .IsTable true }}
type {{ .Name }}ResultIterator func(ctx context.Context, result *{{ .Table.GoName }}) (err error)
type {{ .Name }}ResultIterator func(ctx context.Context, result *{{ .Table.GoName }}Row) (err error)
{{ else }}
type {{ .Name }}Result struct { {{ range $key, $field := .ResultFields}}
{{ $field.Name }} {{ $field.Type }} {{ $field.Tags }}{{ end }}
Expand All @@ -44,7 +44,7 @@ func {{ .Name }}(ctx dalc.PreparedContext, request *{{ .Name }}Request, iterator
}

{{ if eq .IsTable true }}
result := &{{ .Table.GoName }}{}
result := &{{ .Table.GoName }}Row{}
scanErr := result.scanSQLRow(rows)
{{ else }}
result := &{{ .Name }}Result{}
Expand Down
4 changes: 2 additions & 2 deletions cmd/dalc/internal/generates/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package generates
import (
"bytes"
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/commons"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/commons"
"strings"
"text/template"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/generates/template.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package generates

import "github.com/pharosnet/dalc/cmd/dalc/internal/entry"
import "github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"

type TemplateData struct {
Package string
Expand Down
6 changes: 0 additions & 6 deletions cmd/dalc/internal/parser/commons/block.go

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/commons/strings_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package commons_test

import (
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/commons"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/commons"
"testing"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/commons/words_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package commons_test

import (
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/commons"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/commons"
"testing"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/change.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mysql

import "github.com/pharosnet/dalc/cmd/dalc/internal/entry"
import "github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"

const (
TableDropChangeKind = "DROP TABLE"
Expand Down
4 changes: 2 additions & 2 deletions cmd/dalc/internal/parser/mysql/parse_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package mysql

import (
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/commons"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/commons"
"github.com/vitessio/vitess/go/vt/sqlparser"
"reflect"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_query_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mysql

import (
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/vitessio/vitess/go/vt/sqlparser"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_query_delete_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mysql_test

import (
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/mysql"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/mysql"
"io/ioutil"
"os"
"path/filepath"
Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_query_exprs.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mysql

import (
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/vitessio/vitess/go/vt/sqlparser"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_query_insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mysql

import (
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/vitessio/vitess/go/vt/sqlparser"
"reflect"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_query_insert_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mysql_test

import (
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/mysql"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/mysql"
"io/ioutil"
"os"
"path/filepath"
Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_query_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mysql

import (
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/vitessio/vitess/go/vt/sqlparser"
"reflect"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_query_select_limit.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mysql

import (
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/vitessio/vitess/go/vt/sqlparser"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mysql

import (
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/vitessio/vitess/go/vt/sqlparser"
"reflect"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mysql

import (
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/vitessio/vitess/go/vt/sqlparser"
"reflect"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_query_select_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mysql_test

import (
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/mysql"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/mysql"
"io/ioutil"
"os"
"path/filepath"
Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_query_select_where.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mysql
import (
"bytes"
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/vitessio/vitess/go/vt/sqlparser"
"reflect"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_query_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mysql_test

import (
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/mysql"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/mysql"
"io/ioutil"
"os"
"path/filepath"
Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_query_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mysql

import (
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/vitessio/vitess/go/vt/sqlparser"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_query_update_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mysql_test

import (
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/mysql"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/mysql"
"io/ioutil"
"os"
"path/filepath"
Expand Down
4 changes: 2 additions & 2 deletions cmd/dalc/internal/parser/mysql/parse_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package mysql

import (
"fmt"
"github.com/pharosnet/dalc/cmd/dalc/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/commons"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/entry"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/commons"
"strings"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/dalc/internal/parser/mysql/parse_schema_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mysql_test

import (
"github.com/pharosnet/dalc/cmd/dalc/internal/parser/mysql"
"github.com/pharosnet/dalc/cmd/dalc/v2/internal/parser/mysql"
"io/ioutil"
"os"
"path/filepath"
Expand Down
Loading

0 comments on commit 6ec8203

Please sign in to comment.