Skip to content

Commit 49a235e

Browse files
committed
Store a Semver in a Version
1 parent c68ab80 commit 49a235e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/version.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use util::errors::NotFound;
1717
pub struct Version {
1818
pub id: i32,
1919
pub package_id: i32,
20-
pub num: String,
20+
pub num: semver::Version,
2121
pub updated_at: Timespec,
2222
pub created_at: Timespec,
2323
pub downloads: i32,
@@ -36,10 +36,11 @@ pub struct EncodableVersion {
3636

3737
impl Version {
3838
pub fn from_row(row: &PostgresRow) -> Version {
39+
let num: String = row.get("num");
3940
Version {
4041
id: row.get("id"),
4142
package_id: row.get("package_id"),
42-
num: row.get("num"),
43+
num: semver::Version::parse(num.as_slice()).unwrap(),
4344
updated_at: row.get("updated_at"),
4445
created_at: row.get("created_at"),
4546
downloads: row.get("downloads"),
@@ -87,6 +88,7 @@ impl Version {
8788
let Version { id, package_id, num, updated_at, created_at,
8889
downloads } = self;
8990
assert_eq!(pkg.id, package_id);
91+
let num = num.to_string();
9092
EncodableVersion {
9193
dl_path: pkg.dl_path(num.as_slice()),
9294
num: num,

0 commit comments

Comments
 (0)