File tree 1 file changed +20
-13
lines changed 1 file changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -27,19 +27,26 @@ fn transfer(tx: &postgres::transaction::Transaction) {
27
27
for row in rows. iter ( ) {
28
28
let id: i32 = row. get ( "id" ) ;
29
29
let name: String = row. get ( "name" ) ;
30
- let license: String = row. get ( "license" ) ;
31
-
32
- println ! (
33
- "Setting the license for all versions of {} to {}." ,
34
- name,
35
- license
36
- ) ;
37
-
38
- let num_updated = tx. execute (
39
- "UPDATE versions SET license = $1 WHERE crate_id = $2" ,
40
- & [ & license, & id] ,
41
- ) . unwrap ( ) ;
42
- assert ! ( num_updated > 0 ) ;
30
+ let license: Option < String > = row. get ( "license" ) ;
31
+
32
+ if let Some ( license) = license {
33
+ println ! (
34
+ "Setting the license for all versions of {} to {}." ,
35
+ name,
36
+ license
37
+ ) ;
38
+
39
+ let num_updated = tx. execute (
40
+ "UPDATE versions SET license = $1 WHERE crate_id = $2" ,
41
+ & [ & license, & id] ,
42
+ ) . unwrap ( ) ;
43
+ assert ! ( num_updated > 0 ) ;
44
+ } else {
45
+ println ! (
46
+ "Ignoring crate `{}` because it doesn't have a license." ,
47
+ name
48
+ ) ;
49
+ }
43
50
}
44
51
45
52
get_confirm ( "Finish committing?" ) ;
You can’t perform that action at this time.
0 commit comments