-
-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add force-simple parameter when copying #723
Conversation
4d2da6b
to
b73553d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great! love the :memory:
usage for the tests, so much cleaner now. See inline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For copying, seems like we may have a bug - when copying schema, we should copy tables before indexes. If we don't have any order by
, it may fail
martin-mbtiles/src/tile_copier.rs
Outdated
@@ -267,18 +279,40 @@ mod tests { | |||
)); | |||
} | |||
|
|||
#[actix_rt::test] | |||
async fn copy_force_simple() { | |||
let src_filepath = PathBuf::from("../tests/fixtures/files/world_cities.mbtiles"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May want to call them same as other tests for consistency
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing: please add this function to the tests (welcome to modify it if needed)
async fn get_one<T>(conn: &mut SqliteConnection, sql: &str) -> T
where
for<'r> T: Decode<'r, Sqlite> + Type<Sqlite>,
{
query(sql).fetch_one(conn).await.unwrap().get::<T, _>(0)
}
This way you can get a single value with simpler code:
get_one::<u8>(&mut dst_conn, "SELECT COUNT(DISTINCT zoom_level) FROM tiles;").await
instead of the one you have
query("SELECT COUNT(DISTINCT zoom_level) FROM tiles;")
.fetch_one(&mut dst_conn)
.await
.unwrap()
.get::<u8, _>(0),
43b4d3b
to
1661128
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost there! a few comments
martin-mbtiles/src/tile_copier.rs
Outdated
@@ -267,18 +279,40 @@ mod tests { | |||
)); | |||
} | |||
|
|||
#[actix_rt::test] | |||
async fn copy_force_simple() { | |||
let src_filepath = PathBuf::from("../tests/fixtures/files/world_cities.mbtiles"); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, thank you!
assert_eq!( | ||
Args::try_parse_from(["mbtiles", "copy"]) | ||
.unwrap_err() | ||
.kind(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice find!
Add
--force-simple
flag tombtiles copy
tool.If supplied, ensures the destination file has a
tiles
table (as opposed to atiles
view made up ofimages
andmap
tables).