forked from G-Research/fasttrackml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various fixes for multiple value columns
- Loading branch information
Showing
8 changed files
with
67 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,42 @@ | ||
package models | ||
|
||
import "fmt" | ||
import ( | ||
"fmt" | ||
) | ||
|
||
// Param represents model to work with `params` table. | ||
type Param struct { | ||
Key string `gorm:"type:varchar(250);not null;primaryKey"` | ||
Value string `gorm:"type:varchar(500);not null"` | ||
ValueStr *string `gorm:"type:varchar(500)"` | ||
ValueInt *int64 `gorm:"type:bigint"` | ||
ValueFloat *float64 `gorm:"type:float"` | ||
RunID string `gorm:"column:run_uuid;not null;primaryKey;index"` | ||
} | ||
|
||
// ValueString returns the value held by this Param as a string | ||
// Value returns the value held by this Param as a string. | ||
func (p Param) ValueString() string { | ||
if p.ValueInt != nil { | ||
switch { | ||
case p.ValueInt != nil: | ||
return fmt.Sprintf("%v", *p.ValueInt) | ||
} else if p.ValueFloat != nil { | ||
case p.ValueFloat != nil: | ||
return fmt.Sprintf("%v", *p.ValueFloat) | ||
} else { | ||
return p.Value | ||
case p.ValueStr != nil: | ||
return *p.ValueStr | ||
default: | ||
return "" | ||
} | ||
} | ||
|
||
// ValueAny returns the value held by this Param as any | ||
// ValueAny returns the value held by this Param as any with underlying type. | ||
func (p Param) ValueAny() any { | ||
if p.ValueInt != nil { | ||
switch { | ||
case p.ValueInt != nil: | ||
return *p.ValueInt | ||
} else if p.ValueFloat != nil { | ||
case p.ValueFloat != nil: | ||
return *p.ValueFloat | ||
} else { | ||
return p.Value | ||
case p.ValueStr != nil: | ||
return *p.ValueStr | ||
default: | ||
return nil | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters