aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2022-03-28README: Add a note about pre-built binariesHEADmasterTeddy Wing
2022-03-28Makefile: Add targets for binary packagingTeddy Wing
2022-03-27Add license (GNU GPLv3+)v0.0.1Teddy Wing
2022-03-27README: Add installation command for non-Mac platformsTeddy Wing
2022-03-27README: Remove extra indentation in `CREATE TABLE` queryTeddy Wing
It's unnecessary.
2022-03-27README: Change the line breaks in the usage exampleTeddy Wing
Separate the paragraphs with an empty line.
2022-03-27README: Add usage exampleTeddy Wing
2022-03-27Start READMETeddy Wing
2022-03-27yaqlite.1.txt: Add command descriptionsTeddy Wing
2022-03-27yaqlite.1.txt: Describe subcommand optionsTeddy Wing
2022-03-25yaqlite.1.txt: Add global flags and short subcommand descriptionTeddy Wing
2022-03-23Start writing man pageTeddy Wing
2022-03-23extract(): Rename function to `db_insert()`Teddy Wing
The name `extract()` didn't make sense to me any more since the function is doing more than its originally intended behaviour which was to extract the YAML into a hash-like format for easy insertion into the database. I decided to give up on that behaviour since this works for what we want it to do. Maybe this function is doing more than it should, but I'm okay with that for the current functional requirements.
2022-03-23insert(): Add documentationTeddy Wing
2022-03-23get_column_names(): Add documentationTeddy Wing
2022-03-23yaml::write: Add documentationTeddy Wing
2022-03-23lib: Add documentation for `Error` typeTeddy Wing
2022-03-23select: Add function documentationTeddy Wing
2022-03-21sql: Add documentationTeddy Wing
2022-03-21sql: Remove `From` impl for `Yaml` idea commentTeddy Wing
This was obviated by using `Cow::Borrowed` and `Cow::Owned` directly when creating a `Yaml`.
2022-03-21Add placeholders for code documentation remindersTeddy Wing
2022-03-21get_column_names(): Use `HashSet` instead of `HashMap`Teddy Wing
This saves us from having to declare and use a vestigial unit struct value for the hash. In retrospect, I could have used the unit type instead of creating a unit struct, but this is even cleaner. Only a couple hours ago learned that `HashSet` exists.
2022-03-21lib: Move `insert()` to a new moduleTeddy Wing
Split this code out into its own module like we've done with `select()`. Feels better organised this way.
2022-03-21sqlite: Remove unused `affinity()` functionTeddy Wing
Turns out I didn't need this. The `ToSql` and `FromSql` type conversion traits were what I needed instead to convert between YAML and SQLite types.
2022-03-21select: Fix test by adding new argumentTeddy Wing
We added a new argument to the `select()` functions in f30a4dafa5736c58bda54569ec9f46e6fdb2e200 to allow columns to be excluded from the YAML output. Update the test to include the new argument in its call. I was getting this error about the `C` type parameter on the function: error[E0282]: type annotations needed --> src/select.rs:152:23 | 152 | let got = select(&conn, "test", "1", None).unwrap(); | ^^^^^^ cannot infer type for type parameter `C` declared on the function `select` For more information about this error, try `rustc --explain E0282`. The error makes sense in a way, but it also doesn't at all, because I'm not passing a `Some` value into the function. If it's a `None`, then what need is there to specify a type that's never used? I wonder if there's a way to get this to work in a way that doesn't require me to specify the type parameter when passing `None` for `exclude_columns`.
2022-03-21get_column_names: Idea for column name storageTeddy Wing
I just learned about `HashSet`, and it looks like a cleaner way to do exactly what I was trying to do with `HashMap`.
2022-03-21Add a couple of notes for code cleanupTeddy Wing
2022-03-20main: Print errors to standard error instead of panicking with `unwrap`Teddy Wing
Use `anyhow` to add context to errors and a `main()` wrapper that prints error messages and their context to standard error.
2022-03-20main: Add an option to include the primary key in outputTeddy Wing
Since the primary key column is excluded by default, there's no way to include it without excluding columns. Provide a way to include the primary key column when no columns have been excluded. Not a very good interface admittedly, but it enables a previously impossible behaviour.
2022-03-20select: Exclude primary key column unless given excluded columnsTeddy Wing
If no excluded columns are given, exclude the primary key column by default. Otherwise, exclude only those columns in the `exclude_columns` list.
2022-03-20select(): Allow columns to be excluded from YAML output hashTeddy Wing
Instead of only excluding the primary key column, exclude any columns in the given list. This allows us to pass a list of excluded columns on the command line.
2022-03-19main: Emit multiline YAML outputTeddy Wing
Only works with `|` YAML instead of `>` flowed output. Use a forked `yaml-rust` crate published by https://github.com/davvid/yaml-rust that includes a patch to support multiline output.
2022-03-19main: Write a newline after YAML outputTeddy Wing
It turns out the `YamlEmitter` doesn't output a newline at the end. Output a final newline as this is a command line program.
2022-03-19main: Write YAML to standard outputTeddy Wing
Create an adapter from `std::fmt::Write` to `std::io::Write` based on the following idea in the standard library: https://github.com/rust-lang/rust/blob/master/library/std/src/io/mod.rs#L1634-L1652 Since `yaml_rust::YamlEmitter::new()` requires a `std::fmt::Write`, adapt standard output so the emitter can write to it.
2022-03-19main: Try to emit serialized YAML to standard outputTeddy Wing
Doesn't work this way as `YamlEmitter` requires `std::fmt::Write` instead of `std::io::Write` (implemented by `Stdout`). Looks like I'll need some kind of intermediary buffer or adapter to convert between the different `Write` traits.
2022-03-19select: Idea for column exclusionTeddy Wing
2022-03-19main: If `primary_key` option is given, select by given column nameTeddy Wing
2022-03-19main: Use `Result` from `yaqlite::select()`Teddy Wing
2022-03-19select: Remove `dbg!` outputTeddy Wing
No longer need this.
2022-03-19select: Handle multiple records foundTeddy Wing
If no records were found, continue to return `Yaml::Null`. If a single record was found, return a `Yaml::Hash`. Otherwise, return a `Yaml::Array` containing all the records.
2022-03-19select: Remove in-progress code ideasTeddy Wing
2022-03-19select: Remove unused `HashMap` importTeddy Wing
We switched this to a `yaml_rust::yaml::Hash`.
2022-03-19select: Remove `select_by_column()` idea codeTeddy Wing
This is implemented now.
2022-03-19select(): Parameterize primary key column nameTeddy Wing
2022-03-19select(): Column name interface and default primary key column interfaceTeddy Wing
Add a new function that allows using a specified column name for selection. The `select()` function will default to using the table's primary key column. Still need to update the references to the "id" column in the function.
2022-03-19select(): Remove `unwrap()`sTeddy Wing
2022-03-19select(): Idea for selecting by a custom column nameTeddy Wing
2022-03-19select(): Don't include the primary key in the `Yaml` hashTeddy Wing
The primary key shouldn't be editable, so don't include it in the resulting YAML.
2022-03-19select(): Change `column_name` extraction to `to_owned()`Teddy Wing
I had used `to_string()` before because the in-progress code wouldn't let me use `to_owned()`. Now that I've changed things around, this is possible.
2022-03-19select(): Change `column_names` to `Vec<String>`Teddy Wing
Change `column_names` from `Vec<yaml_rust::Yaml::String>` to `Vec<String>`. This way we don't have to clone the `yaml_rust::Yaml` value to insert into the `yaml_rust::yaml::Hash`. Had some issues getting this to work. I tried calling `stmt.column_names()` on its own, but this caused a borrow checker error, as that creates an immutable borrow, while the `stmt.query_map()` call is a mutable borrow, and we can't do both. Found this ticket that describes exactly the problem I was having: https://github.com/rusqlite/rusqlite/pull/523 Turns out I had the right idea to begin with: I needed to collect the column names into a `Vec`. But don't use a `Vec` of `yaml_rust::Yaml` values, because that requires excess cloning.