diff --git a/src/interactive.rs b/src/interactive.rs index 7b5d4c5a3..8cb8076ed 100644 --- a/src/interactive.rs +++ b/src/interactive.rs @@ -149,7 +149,7 @@ pub fn main(options: Options, cfg: Config) -> Result<(), anyhow::Error> { pub async fn _main(options: Options, mut state: repl::State, cfg: Config) -> anyhow::Result<()> { - state.reconnect().await?; + state.connect().await?; if let Some(config_path) = &cfg.file_name { echo!( format_args!("Applied {} configuration file", diff --git a/src/repl.rs b/src/repl.rs index 4f793db9e..75f55a324 100644 --- a/src/repl.rs +++ b/src/repl.rs @@ -121,9 +121,23 @@ impl PromptRpc { } impl State { + pub async fn connect(&mut self) -> anyhow::Result<()> { + let db = self.conn_params.get()?.database().to_owned(); + self.try_connect(&db).await?; + Ok(()) + } pub async fn reconnect(&mut self) -> anyhow::Result<()> { let db = self.conn_params.get()?.database().to_owned(); + let cur_state = self.edgeql_state.clone(); + let cur_state_desc = self.edgeql_state_desc.clone(); self.try_connect(&db).await?; + if let Some(conn) = &mut self.connection { + if cur_state_desc == self.edgeql_state_desc { + conn.set_state(cur_state); + } else { + eprintln!("Discarding session configuration because server configuration layout has changed."); + } + } Ok(()) } pub async fn set_idle_transaction_timeout(&mut self) -> anyhow::Result<()> {