@@ -84,21 +84,24 @@ class ConfigParser {
8484 throw SQLite::Exception (" GenomicSQLite::ConfigParser()::sqlite3_open_v2()" , rc);
8585 }
8686
87- // merge config_json into defaults
88- if ((rc = sqlite3_prepare_v2 (db_, " SELECT json_patch(?,?)" , -1 , &patch_, nullptr )) !=
89- SQLITE_OK)
90- throw SQLite::Exception (db_, rc);
91- if ((rc = sqlite3_bind_text (patch_, 1 , GenomicSQLiteDefaultConfigJSON ().c_str (), -1 ,
92- SQLITE_TRANSIENT)) != SQLITE_OK)
93- throw SQLite::Exception (db_, rc);
94- if ((rc = sqlite3_bind_text (patch_, 2 , config_json.c_str (), -1 , SQLITE_TRANSIENT)) !=
95- SQLITE_OK)
96- throw SQLite::Exception (db_, rc);
97- const char *merged_config_json = nullptr ;
98- if ((rc = sqlite3_step (patch_)) != SQLITE_ROW ||
99- !(merged_config_json = (const char *)sqlite3_column_text (patch_, 0 )) ||
100- merged_config_json[0 ] != ' {' ) {
101- throw SQLite::Exception (" error parsing config JSON" , rc);
87+ string default_json = GenomicSQLiteDefaultConfigJSON ();
88+ const char *merged_config_json = default_json.c_str ();
89+ if (config_json.size () > 2 ) { // "{}"
90+ // merge config_json into defaults
91+ if ((rc = sqlite3_prepare_v2 (db_, " SELECT json_patch(?,?)" , -1 , &patch_, nullptr )) !=
92+ SQLITE_OK)
93+ throw SQLite::Exception (db_, rc);
94+ if ((rc = sqlite3_bind_text (patch_, 1 , default_json.c_str (), -1 , SQLITE_TRANSIENT)) !=
95+ SQLITE_OK)
96+ throw SQLite::Exception (db_, rc);
97+ if ((rc = sqlite3_bind_text (patch_, 2 , config_json.c_str (), -1 , SQLITE_TRANSIENT)) !=
98+ SQLITE_OK)
99+ throw SQLite::Exception (db_, rc);
100+ if ((rc = sqlite3_step (patch_)) != SQLITE_ROW ||
101+ !(merged_config_json = (const char *)sqlite3_column_text (patch_, 0 )) ||
102+ merged_config_json[0 ] != ' {' ) {
103+ throw SQLite::Exception (" error parsing config JSON" , rc);
104+ }
102105 }
103106
104107 if ((rc = sqlite3_prepare_v2 (db_, " SELECT json_extract(?,?)" , -1 , &extract_, nullptr )) !=
0 commit comments