Skip to content

Commit

Permalink
add other date type supports
Browse files Browse the repository at this point in the history
  • Loading branch information
borosr committed Feb 24, 2021
1 parent d49d3f5 commit db7b4a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions drivers/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
Bool
Json
Time
Year
Unknown
)

Expand Down
12 changes: 8 additions & 4 deletions drivers/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,17 @@ func (m MySQL) MapField(field string) Field {
return Field{Type: Json, Length: -1}
}

// Date
// Timestamp
// Time
// Year
if strings.HasPrefix(field, "year") {
return Field{Type: Year, Length: 4}
}

// Time
// Date
// Timestamp
// Datetime
if strings.HasPrefix(field, "datetime") {
if strings.HasPrefix(field, "datetime") || strings.HasPrefix(field, "date") ||
strings.HasPrefix(field, "timestamp") || strings.HasPrefix(field, "time") {
return Field{Type: Time, Length: -1}
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func generateData(driver drivers.Driver, t string) interface{} {
)
case drivers.Time:
return gofakeit.Date()
case drivers.Year:
return gofakeit.Number(1901, 2155)
case drivers.Unknown:
log.Fatalf("Unknown field type: %s", t)
}
Expand Down

0 comments on commit db7b4a9

Please sign in to comment.