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

[soci/4.0.3,sqlite3] executed on an empty table bulk select operation returns a vector with size 1 if called with a vector with size 1 #1188

Open
werto87 opened this issue Dec 30, 2024 · 0 comments

Comments

@werto87
Copy link

werto87 commented Dec 30, 2024

Problem:
executed on an empty table bulk select operation returns a vector with size 1 if called with a vector with size 1.

What I expect:
The table is empty so the vector should have a size of 0 after executing the select statement.

Additional Information (works if I pass a vector with size 2)
executed on an empty table bulk select operation returns a vector with size 0 if called with a vector with size 2.

How to reproduce:
run this catch2 test

TEST_CASE ("bulk operation", "[soci]")
{

  using namespace sqlite_api;
  if (not std::filesystem::exists ("test_db"))
    {
      sqlite3 *db{};
      int rc{};
      rc = sqlite3_open ("test_db", &db);
      if (rc)
        {
          fprintf (stderr, "Can't open database: %s\n", sqlite3_errmsg (db));
          return;
        }
      sqlite3_close (db);
      soci::session sql (soci::sqlite3, "test_db");
      sql << "create table test1 ("
             "    id integer,"
             ")";
    }
  soci::session sql (soci::sqlite3, "test_db");
  int count;
  sql << "select count(*) from test1", soci::into (count);
  CHECK (count == 0);
  auto vec1 = std::vector<int> (1);
  sql << "SELECT id FROM test1", soci::into (vec1);
  CHECK (vec1.empty ());
  auto vec2 = std::vector<int> (2);
  sql << "SELECT id FROM test1", soci::into (vec2);
  CHECK (vec2.empty ());
}
@werto87 werto87 changed the title executed on an empty table bulk select operation returns a vector with size 1 if called with a vector with size 1 [sqlite3] executed on an empty table bulk select operation returns a vector with size 1 if called with a vector with size 1 Dec 30, 2024
@werto87 werto87 changed the title [sqlite3] executed on an empty table bulk select operation returns a vector with size 1 if called with a vector with size 1 [soci/4.0.3,sqlite3] executed on an empty table bulk select operation returns a vector with size 1 if called with a vector with size 1 Dec 30, 2024
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

No branches or pull requests

1 participant