@@ -45,6 +45,7 @@ public class Sequeler.Layouts.Views.Query : Gtk.Grid {
4545
4646 public Gtk . Paned panels;
4747 public Sequeler . Partials . TreeBuilder result_data;
48+ public Sequeler . Widgets . QueryParamsDialog ? params_dialog { get ; set ; default = null ; }
4849
4950 public signal void update_tab_indicator (bool status );
5051
@@ -292,17 +293,9 @@ public class Sequeler.Layouts.Views.Query : Gtk.Grid {
292293 }
293294
294295 public Gtk .Button build_run_button () {
295- run_button = new Gtk .Button .with_label (_(" Run Query" ));
296- run_button. get_style_context (). add_class (" suggested-action" );
297- run_button. get_style_context (). add_class (" notebook-temp-fix" );
298- run_button. always_show_image = true ;
299- run_button. image = new Gtk .Image .from_icon_name (" media-playback-start-symbolic" , Gtk . IconSize . BUTTON );
300- run_button. image. valign = Gtk . Align . CENTER ;
301- run_button. can_focus = false ;
302- run_button. margin = 10 ;
303- run_button. sensitive = false ;
304- run_button. tooltip_markup = Granite . markup_accel_tooltip ({" <Control>Return" }, _(" Run Query" ));
305- run_button. action_name = Services . ActionManager . ACTION_PREFIX + Services . ActionManager . ACTION_RUN_QUERY ;
296+ run_button = new Sequeler .Partials .RunQueryButton ();
297+ run_button. action_name = Services . ActionManager . ACTION_PREFIX
298+ + Services . ActionManager . ACTION_RUN_QUERY ;
306299
307300 return run_button;
308301 }
@@ -396,6 +389,38 @@ public class Sequeler.Layouts.Views.Query : Gtk.Grid {
396389 }
397390
398391 public void run_query (string query ) {
392+ Gda . Statement statement;
393+ Gda . Set params;
394+ try {
395+ statement = window. main. connection_manager. parse_sql_string (query, out params);
396+ } catch (GLib . Error ex) {
397+ on_query_error (ex. message);
398+ return ;
399+ }
400+
401+ if (statement == null || params == null ) {
402+ run_query_statement (query, statement, null );
403+ return ;
404+ }
405+
406+ for (int i = 0 ; ; i++ ) {
407+ var holder = params. get_nth_holder (i);
408+ if (holder == null ) {
409+ break ;
410+ }
411+ debug (" holder #%d is %s type: %s " , i, holder. get_id (), holder. get_g_type (). name ());
412+ }
413+
414+ params_dialog = new Sequeler .Widgets .QueryParamsDialog (window, this , query, statement, params);
415+ params_dialog. set_modal (true );
416+ params_dialog. show_all ();
417+
418+ params_dialog. destroy. connect (() = > {
419+ params_dialog = null ;
420+ });
421+ }
422+
423+ public void run_query_statement (string query , Gda .Statement statement , Gda .Set ? params ) {
399424 toggle_loading_msg (true );
400425 spinner. start ();
401426
@@ -405,22 +430,22 @@ public class Sequeler.Layouts.Views.Query : Gtk.Grid {
405430 var explain_pos = query. down (). index_of (" explain" , 0 );
406431
407432 if (select_pos == 0 || show_pos == 0 || pragma_pos == 0 || explain_pos == 0 ) {
408- select_statement. begin (query , (obj, res) = > {
433+ select_statement. begin (statement, params , (obj, res) = > {
409434 handle_select_response (select_statement. end (res));
410435 });
411436 } else {
412- non_select_statement. begin (query , (obj, res) = > {
437+ non_select_statement. begin (statement, params , (obj, res) = > {
413438 handle_query_response (non_select_statement. end (res));
414439 });
415440 }
416441 }
417442
418- private async Gee .HashMap<Gda . DataModel ?, string > select_statement (string query ) {
419- return yield window. main. connection_manager. init_silent_select_query (query );
443+ private async Gee .HashMap<Gda . DataModel ?, string > select_statement (Gda . Statement statement , Gda . Set ? params ) {
444+ return yield window. main. connection_manager. init_silent_select_statement (statement, params );
420445 }
421446
422- public async Gee .HashMap<string?, string> non_select_statement (string query ) {
423- return yield window. main. connection_manager. init_silent_query (query );
447+ public async Gee .HashMap<string?, string> non_select_statement (Gda . Statement statement , Gda . Set ? params ) {
448+ return yield window. main. connection_manager. init_silent_statement (statement, params );
424449 }
425450
426451 public void handle_select_response (Gee .HashMap<Gda . DataModel ?, string > response ) {
0 commit comments