Skip to content

Commit

Permalink
Fix error in applyChangeset when a trigger contains space (fixes #137)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Jul 27, 2021
1 parent 5512a50 commit 42cedca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion geodiff/src/drivers/sqlitedriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ void SqliteDriver::applyChangeset( ChangesetReader &reader )
Sqlite3Stmt statament;
for ( std::string name : triggerNames )
{
statament.prepare( mDb, "drop trigger %s", name.c_str() );
statament.prepare( mDb, "drop trigger '%q'", name.c_str() );
sqlite3_step( statament.get() );
statament.close();
}
Expand Down
11 changes: 11 additions & 0 deletions geodiff/tests/test_driver_sqlite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,17 @@ TEST( SqliteDriverTest, apply_changeset_delete )
);
}

TEST( SqliteDriverTest, apply_changeset_trigger_with_spaces )
{
// the testing database is just like base.gpkg, but it has an extra dummy trigger:
// CREATE TRIGGER "trigger with space" AFTER DELETE ON simple BEGIN DELETE FROM simple; END;
testApplyChangeset( "test_apply_changeset_trigger_with_spaces",
pathjoin( testdir(), "quoting", "trigger-with-space.gpkg" ),
pathjoin( testdir(), "1_geopackage", "base-modified_1_geom.diff" ),
pathjoin( testdir(), "1_geopackage", "modified_1_geom.gpkg" )
);
}

TEST( SqliteDriverTest, apply_changeset_conflict )
{
// the diff file contains one regular delete and one wrong delete
Expand Down
Binary file not shown.

0 comments on commit 42cedca

Please sign in to comment.