Open jlpoolen opened 9 months ago
Here's the diff of the modified example so that it works. There are 2 modifications and 1 deletion.
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $ diff src/original_main.rs src/main.rs
7c7
< use rusqlite::NO_PARAMS;
---
> //use rusqlite::NO_PARAMS;
17c17
< NO_PARAMS,
---
> (),
25c25
< NO_PARAMS,
---
> (),
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $ date; cargo run
Tue Jan 2 05:44:52 PM PST 2024
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/rusqlite1`
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $
Likewise, the 2nd example suffers from the illegal NO_PARAMS variable. I replaced NO_PARAMS with "()" and now the example with the 2nd code added works.
Tue Jan 2 05:55:26 PM PST 2024
Compiling rusqlite1 v0.1.0 (/home/jlpoole/adsb/tests/rust/rusqlite1)
error[E0425]: cannot find value `NO_PARAMS` in this scope
--> src/main.rs:59:31
|
59 | let cats = stmt.query_map(NO_PARAMS, |row| {
| ^^^^^^^^^ not found in this scope
For more information about this error, try `rustc --explain E0425`.
error: could not compile `rusqlite1` (bin "rusqlite1") due to previous error
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $ sed -i s/NO_PARAMS/\(\)/ src/main.rs
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $ cat src/main.rs |grep NO_PARAMS
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $ date;cargo run
Tue Jan 2 05:56:59 PM PST 2024
Compiling rusqlite1 v0.1.0 (/home/jlpoole/adsb/tests/rust/rusqlite1)
warning: fields `name` and `color` are never read
--> src/main.rs:12:5
|
11 | struct Cat {
| --- fields in this struct
12 | name: String,
| ^^^^
13 | color: String,
| ^^^^^
|
= note: `Cat` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
= note: `#[warn(dead_code)]` on by default
warning: `rusqlite1` (bin "rusqlite1") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.32s
Running `target/debug/rusqlite1`
Error: SqliteFailure(Error { code: ConstraintViolation, extended_code: 2067 }, Some("UNIQUE constraint failed: cat_colors.name"))
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $ rm cats.db
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $ date;cargo run
Tue Jan 2 05:57:17 PM PST 2024
warning: fields `name` and `color` are never read
--> src/main.rs:12:5
|
11 | struct Cat {
| --- fields in this struct
12 | name: String,
| ^^^^
13 | color: String,
| ^^^^^
|
= note: `Cat` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
= note: `#[warn(dead_code)]` on by default
warning: `rusqlite1` (bin "rusqlite1") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/rusqlite1`
Found cat Ok(Cat { name: "Oreo", color: "Black" })
Found cat Ok(Cat { name: "Biscuit", color: "Black" })
Found cat Ok(Cat { name: "Tigger", color: "Blue" })
Found cat Ok(Cat { name: "Sammy", color: "Blue" })
jlpoole@ryzdesk ~/adsb/tests/rust/rusqlite1 $