Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query recorder #80

Open
julianhyde opened this issue Dec 16, 2024 · 0 comments · May be fixed by #85
Open

Query recorder #80

julianhyde opened this issue Dec 16, 2024 · 0 comments · May be fixed by #85

Comments

@julianhyde
Copy link
Collaborator

Add a component that can record queries to Quidem files and play them back.

Here is an example:

// The first recorder, in record mode, creates "foo.iq".
ConnectionFactory postgres;
Config config = Config.empty()
  .withFile("foo.iq")
  .withMode(RECORD)
  .withConnectionFactory(postgres);
Recorder recorder = Recorder.create(config);
recorder.executeQuery("select count(*) from emp", "empCount", result -> {
    assertThat(result.getMetaData().getColumnCount(), is(1));
    assertThat(result.next(), is(true));
    assertThat(result.getInt(1), is(13));
  });
recorder.close();

// The second recorder, in play mode, reads "foo.iq" created by the first step.
Config config2 = Config.empty()
  .withFile("foo.iq")
  .withMode(PLAY);
Recorder recorder2 = Recorder.create(config);
recorder.executeQuery("select count(*) from emp", result -> {
    assertThat(result.getMetaData().getColumnCount(), is(1));
    assertThat(result.next(), is(true));
    assertThat(result.getInt(1), is(13));
  });
recorder2.close();

Here is the foo.iq file that is generated in step 1 and read in step 2:

!use "postgres"

# empCount
select count(*) as c from emp;
c:int
======
13
!ok
@julianhyde julianhyde linked a pull request Dec 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant