diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2023-02-13 12:52:10 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2023-02-14 16:01:56 +0000 |
commit | 107cabc09f3dad5aa822517401be7bc802e3e527 (patch) | |
tree | d19089a9252e0ab09faa304486edd95099d9fe75 /src | |
parent | 215f8f9fde3f30ed0e5c8865ea9acc9368f3fc42 (diff) | |
download | tracker-107cabc09f3dad5aa822517401be7bc802e3e527.tar.gz |
libtracker-sparql: Fall back to updates parsing loading SPARQL from GResource
This is a single API entrypoint that may create either select or update
statements. Make it handle properly both by falling back. If the SPARQL was
not parsed by either, an error is picked and raised.
Diffstat (limited to 'src')
-rw-r--r-- | src/libtracker-sparql/tracker-connection.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libtracker-sparql/tracker-connection.c b/src/libtracker-sparql/tracker-connection.c index a62eb21cc..fcc4ba3b3 100644 --- a/src/libtracker-sparql/tracker-connection.c +++ b/src/libtracker-sparql/tracker-connection.c @@ -789,6 +789,7 @@ tracker_sparql_connection_load_statement_from_gresource (TrackerSparqlConnection { TrackerSparqlStatement *stmt; GBytes *query; + GError *inner_error1 = NULL, *inner_error2 = NULL; g_return_val_if_fail (TRACKER_IS_SPARQL_CONNECTION (connection), NULL); g_return_val_if_fail (resource_path && *resource_path, NULL); @@ -805,7 +806,21 @@ tracker_sparql_connection_load_statement_from_gresource (TrackerSparqlConnection g_bytes_get_data (query, NULL), cancellable, - error); + &inner_error1); + + if (inner_error1) { + stmt = TRACKER_SPARQL_CONNECTION_GET_CLASS (connection)->update_statement (connection, + g_bytes_get_data (query, + NULL), + cancellable, + &inner_error2); + if (inner_error1 && inner_error2) { + /* Pick one */ + g_propagate_error (error, inner_error1); + g_clear_error (&inner_error2); + } + } + g_bytes_unref (query); return stmt; |