Giter Club home page Giter Club logo

Comments (2)

rbock avatar rbock commented on July 22, 2024 1

Hi Davis,

I just gave it a try: Works fine for me.

Here's my test code:

#include "TabSample.h"
#include <sqlpp11/sqlpp11.h>
#include <sqlpp11/custom_query.h>
#include <sqlpp11/sqlite3/sqlite3.h>

#include <sqlite3.h>
#include <iostream>
#include <set>
#include <cassert>


SQLPP_ALIAS_PROVIDER(left);

namespace sql = sqlpp::sqlite3;
int main()
{
  sql::connection_config config;
  config.path_to_database = ":memory:";
  config.flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
  config.debug = true;

  sql::connection db(config);
  db.execute(R"(CREATE TABLE tab_sample (
    alpha INTEGER PRIMARY KEY AUTOINCREMENT,
      beta bool DEFAULT NULL,
      gamma varchar(255) DEFAULT NULL
      ))");

  TabSample tab;
  db(insert_into(tab).default_values());
  db(insert_into(tab).default_values());
  db(insert_into(tab).default_values());

  std::set<int64_t> results;
  for(const auto& row : db(select(all_of(tab)).from(tab).where(true)))
  {
    results.insert(row.alpha);
  };
  const auto expected = std::set<int64_t>{1,2,3};
  assert(results == expected);

  return 0;
}

Please re-open if you have an example that shows a problem.

Thanks and regards,

Roland

from sqlpp11.

rbock avatar rbock commented on July 22, 2024

Hi Davis,

Thanks for your mail. That does not sound good!

As I am at CppCon this week and won't have too much time to do
experiments, could you try to boil it down into a minimalistic example
that compiles?

Best,

Roland

On 2015-09-22 00:51, daviswalker wrote:

Hello there and thank you for a really neat library! I would like to
use autoincrement primary keys but am seeing some unexpected behavior.

CREATE TABLE user (
id int AUTO_INCREMENT PRIMARY KEY,
phone varchar(255) DEFAULT NULL
)

If I insert into this table with:
db(insert_into(table).default_values() and then do a select of all
rows, I see my id field with _is_null set to true and a value of 0, no
matter how many times I insert. select statements that query by id do
not return any results. The return value from my insert calls are
auto-incrementing, so it seems like the data's getting down to the
sqlite3 layer. Any idea what might be going on?

Thanks again.


Reply to this email directly or view it on GitHub
#52.

from sqlpp11.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.