Skip to content

Commit

Permalink
Merge pull request #131 from alexj212/master
Browse files Browse the repository at this point in the history
v0.9.25 release
  • Loading branch information
alexj212 authored Jul 26, 2020
2 parents 2a11192 + 46f8320 commit b0b5bcf
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 98 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,6 @@ gen_readme: ## generate readme file
--connstr "./example/sample.db" \
--database main \
--table invoices


release: fmt gen install example gen_readme ## prepare release
21 changes: 14 additions & 7 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _test/dbmeta/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func init() {
goopt.Description = func() string {
return "ORM and RESTful meta data viewer for SQl databases"
}
goopt.Version = "v0.9.24 (07/13/2020)"
goopt.Version = "v0.9.25 (07/26/2020)"
goopt.Summary = `dbmeta [-v] --sqltype=mysql --connstr "user:password@/dbname" --database <databaseName>
sqltype - sql database type such as [ mysql, mssql, postgres, sqlite, etc. ]
Expand Down
3 changes: 2 additions & 1 deletion code_dao_gorm.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func GetAllInvoices(ctx context.Context, page, pagesize int64, order string) (re
// GetInvoices is a function to get a single record from the invoices table in the main database
// error - ErrNotFound, db Find error
func GetInvoices(ctx context.Context, argInvoiceID int32, ) (record *model.Invoices, err error) {
if err = DB.First(&record, argInvoiceID, ).Error; err != nil {
record = &model.Invoices{}
if err = DB.First(record, argInvoiceID, ).Error; err != nil {
err = ErrNotFound
return record, err
}
Expand Down
6 changes: 3 additions & 3 deletions code_http.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func GetInvoices(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
// @Failure 400 {object} api.HTTPError
// @Failure 404 {object} api.HTTPError
// @Router /invoices [post]
// echo '{"billing_city": "cjuHwSGtQsvxoudomCbYKIpzZ","billing_state": "ZYmdoDEweNWlqtWNoZnIoLHSU","billing_postal_code": "EXQosbeNyzdoEZxEsunUdwKab","total": 0.4938656834813154,"invoice_id": 72,"customer_id": 86,"invoice_date": "2092-01-02T22:21:00.61433147-05:00","billing_address": "dfaDgvowdMJWOQrTfwwNUVAcN","billing_country": "igXpMTfRsqHWhALluklMJLYZK"}' | http POST "http://127.0.0.1:8080/invoices" X-Api-User:user123
// echo '{"invoice_date": "2311-01-24T01:05:44.420640458-05:00","billing_postal_code": "EOINbzuauKmMHiaDymdYsvXDx","billing_country": "cqtEUexVoitsOvqknKNnhShPI","total": 0.932417421427433,"invoice_id": 50,"customer_id": 37,"billing_address": "UgIfqiLZTewHKFZZuTZDwdHpf","billing_city": "mWRUstvZAmHtOuvtsJzocfFFw","billing_state": "gInXWdcekISCnmaDBcsDRWcyB"}' | http POST "http://127.0.0.1:8080/invoices" X-Api-User:user123
func AddInvoices(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
ctx := initializeContext(r)
invoices := &model.Invoices{}
Expand Down Expand Up @@ -191,8 +191,8 @@ func AddInvoices(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
// @Success 200 {object} model.Invoices
// @Failure 400 {object} api.HTTPError
// @Failure 404 {object} api.HTTPError
// @Router /invoices/{argInvoiceID} [patch]
// echo '{"billing_city": "cjuHwSGtQsvxoudomCbYKIpzZ","billing_state": "ZYmdoDEweNWlqtWNoZnIoLHSU","billing_postal_code": "EXQosbeNyzdoEZxEsunUdwKab","total": 0.4938656834813154,"invoice_id": 72,"customer_id": 86,"invoice_date": "2092-01-02T22:21:00.61433147-05:00","billing_address": "dfaDgvowdMJWOQrTfwwNUVAcN","billing_country": "igXpMTfRsqHWhALluklMJLYZK"}' | http PUT "http://127.0.0.1:8080/invoices/1" X-Api-User:user123
// @Router /invoices/{argInvoiceID} [put]
// echo '{"invoice_date": "2311-01-24T01:05:44.420640458-05:00","billing_postal_code": "EOINbzuauKmMHiaDymdYsvXDx","billing_country": "cqtEUexVoitsOvqknKNnhShPI","total": 0.932417421427433,"invoice_id": 50,"customer_id": 37,"billing_address": "UgIfqiLZTewHKFZZuTZDwdHpf","billing_city": "mWRUstvZAmHtOuvtsJzocfFFw","billing_state": "gInXWdcekISCnmaDBcsDRWcyB"}' | http PUT "http://127.0.0.1:8080/invoices/1" X-Api-User:user123
func UpdateInvoices(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
ctx := initializeContext(r)

Expand Down
10 changes: 5 additions & 5 deletions dbmeta/meta_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func mysqlParseDDL(ddl string) (colsDDL map[string]string, primaryKeys []string)
colsDDL[name] = colDDL
}
} else if strings.HasPrefix(line, "PRIMARY KEY") {
var primaryKeyNums = strings.Count(line, "`")/2
var primaryKeyNums = strings.Count(line, "`") / 2
var count = 0
var currentIdx = 0
var idxL = 0
Expand All @@ -156,15 +156,15 @@ func mysqlParseDDL(ddl string) (colsDDL map[string]string, primaryKeys []string)
break
}
count++
idxL = indexAt(line, "`", currentIdx)
currentIdx = idxL+1
idxR = indexAt(line, "`", currentIdx)
idxL = indexAt(line, "`", currentIdx)
currentIdx = idxL + 1
idxR = indexAt(line, "`", currentIdx)
currentIdx = idxR + 1
primaryKeys = append(primaryKeys, line[idxL+1:idxR])
}
}
}
return
return
}

func find(slice []string, val string) (int, bool) {
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func init() {
goopt.Description = func() string {
return "ORM and RESTful API generator for SQl databases"
}
goopt.Version = "v0.9.24 (07/13/2020)"
goopt.Version = "v0.9.25 (07/26/2020)"
goopt.Summary = `gen [-v] --sqltype=mysql --connstr "user:password@/dbname" --database <databaseName> --module=example.com/example [--json] [--gorm] [--guregu] [--generate-dao] [--generate-proj]
git fetch up
sqltype - sql database type such as [ mysql, mssql, postgres, sqlite, etc. ]
Expand Down Expand Up @@ -1017,6 +1017,9 @@ func regenCmdLine() []string {
cmdLine = append(cmdLine, fmt.Sprintf(" --rest"))
}

cmdLine = append(cmdLine, fmt.Sprintf(" --listen=%s", *serverListen))
cmdLine = append(cmdLine, fmt.Sprintf(" --scheme=%s", *serverScheme))

if *daoGenerate {
cmdLine = append(cmdLine, fmt.Sprintf(" --generate-dao"))
}
Expand Down
Loading

0 comments on commit b0b5bcf

Please sign in to comment.