Fix timestamp SELECT code
This commit is contained in:
parent
411383704c
commit
01e06c0152
|
@ -18,16 +18,16 @@ func GetGamepieceByName(db *sql.DB, name string) (entities.Gamepiece, error) {
|
||||||
func GetCacheTimestampByType(db *sql.DB, cacheType string) (time.Time, error) {
|
func GetCacheTimestampByType(db *sql.DB, cacheType string) (time.Time, error) {
|
||||||
var timestamp string
|
var timestamp string
|
||||||
|
|
||||||
query := "SELECT Stamp FROM CacheTimestamps WHERE CacheType = ?;"
|
query := "SELECT Stamp FROM CacheTimestamp WHERE CacheType = ?;"
|
||||||
err := db.QueryRow(query, cacheType).Scan(×tamp)
|
err := db.QueryRow(query, cacheType).Scan(×tamp)
|
||||||
|
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
return time.Unix(0, 0), nil
|
return time.Unix(0, 0), err
|
||||||
}
|
}
|
||||||
|
|
||||||
stamp, err := time.Parse("2006-01-02 15:04:05", timestamp)
|
stamp, err := time.Parse("2006-01-02 15:04:05", timestamp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return time.Unix(0, 0), nil
|
return time.Unix(0, 0), err
|
||||||
}
|
}
|
||||||
|
|
||||||
return stamp, err
|
return stamp, err
|
||||||
|
|
Loading…
Reference in New Issue