Mirror cleanup
This commit is contained in:
parent
f473761813
commit
dc16c76b93
@ -28,8 +28,10 @@ func isPrintable(s string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO:
|
||||||
var convertibleTypes = []reflect.Type{reflect.TypeOf(time.Time{}), reflect.TypeOf(false), reflect.TypeOf([]byte{})}
|
var convertibleTypes = []reflect.Type{reflect.TypeOf(time.Time{}), reflect.TypeOf(false), reflect.TypeOf([]byte{})}
|
||||||
|
|
||||||
|
// RegEx matches only numeric values
|
||||||
var numericPlaceholderRe = regexp.MustCompile(`\$\d+\$`)
|
var numericPlaceholderRe = regexp.MustCompile(`\$\d+\$`)
|
||||||
|
|
||||||
// ExplainSQL generate SQL string with given parameters, the generated SQL is expected to be used in logger, execute it might introduce a SQL injection vulnerability
|
// ExplainSQL generate SQL string with given parameters, the generated SQL is expected to be used in logger, execute it might introduce a SQL injection vulnerability
|
||||||
|
@ -101,7 +101,6 @@ func TestExplainSQL(t *testing.T) {
|
|||||||
Vars: []interface{}{"jinzhu", 1, 0.1753607109, true, []byte("12345"), tt, &tt, nil, "w@g.\"com", myrole, pwd, &js, &es},
|
Vars: []interface{}{"jinzhu", 1, 0.1753607109, true, []byte("12345"), tt, &tt, nil, "w@g.\"com", myrole, pwd, &js, &es},
|
||||||
Result: fmt.Sprintf(`create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values ("jinzhu", 1, 0.1753607109, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.\"com", "admin", "pass", %v, %v)`, format(jsVal, `"`), format(esVal, `"`)),
|
Result: fmt.Sprintf(`create table users (name, age, height, actived, bytes, create_at, update_at, deleted_at, email, role, pass, json_struct, example_struct) values ("jinzhu", 1, 0.1753607109, true, "12345", "2020-02-23 11:10:10", "2020-02-23 11:10:10", NULL, "w@g.\"com", "admin", "pass", %v, %v)`, format(jsVal, `"`), format(esVal, `"`)),
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for idx, r := range results {
|
for idx, r := range results {
|
||||||
|
@ -16,6 +16,13 @@ import (
|
|||||||
"gorm.io/gorm/schema"
|
"gorm.io/gorm/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// This regular expression seeks to find a sequence of digits (\d+) among zero or more non-digit characters (\D*),
|
||||||
|
// with a possible trailing non-digit character (\D?).
|
||||||
|
|
||||||
|
// For example, values that can pass this regular expression are:
|
||||||
|
// - "123"
|
||||||
|
// - "abc456"
|
||||||
|
// -"%$#@789"
|
||||||
var regFullDataType = regexp.MustCompile(`\D*(\d+)\D?`)
|
var regFullDataType = regexp.MustCompile(`\D*(\d+)\D?`)
|
||||||
|
|
||||||
// Migrator m struct
|
// Migrator m struct
|
||||||
|
@ -22,9 +22,9 @@ require (
|
|||||||
github.com/jackc/pgx/v5 v5.4.2 // indirect
|
github.com/jackc/pgx/v5 v5.4.2 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/mattn/go-sqlite3 v1.14.17 // indirect
|
github.com/mattn/go-sqlite3 v1.14.17 // indirect
|
||||||
github.com/microsoft/go-mssqldb v1.4.0 // indirect
|
github.com/microsoft/go-mssqldb v1.5.0 // indirect
|
||||||
golang.org/x/crypto v0.11.0 // indirect
|
golang.org/x/crypto v0.11.0 // indirect
|
||||||
golang.org/x/text v0.11.0 // indirect
|
golang.org/x/text v0.12.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace gorm.io/gorm => ../
|
replace gorm.io/gorm => ../
|
||||||
|
@ -15,6 +15,22 @@ then
|
|||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Function for checking if binary is installed
|
||||||
|
check_binary() {
|
||||||
|
if ! which "$1" > /dev/null; then
|
||||||
|
( >&2 echo "$2" )
|
||||||
|
# Exit with a nonzero code so that the caller knows the script failed.
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_binary "sqlcmd" "$(cat <<EOF
|
||||||
|
You will need microsoft/sqlcmd to run this script.
|
||||||
|
Install it using your package manager. E.g. for homebrew:
|
||||||
|
brew install sqlcmd
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
|
||||||
# SqlServer for Mac M1
|
# SqlServer for Mac M1
|
||||||
if [[ -z $GITHUB_ACTION ]]; then
|
if [[ -z $GITHUB_ACTION ]]; then
|
||||||
if [ -d tests ]
|
if [ -d tests ]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user