Esempio n. 1
0
 virtual void
 write_expression(sql &cmd) const override {
     cmd.write_function_call(
         _function_name,
         transform(_args, [](const abstract_mapper_base *m)  { return &m->only_column();} )
     );
 }
Esempio n. 2
0
BOOST_FIXTURE_TEST_CASE(test_time_insert_time_select, fixture) {
  using sql::select;
  test1 t;
  odbc::time write(3, 11, 17);
  db.execute(insert_into(t)(t.id, t.val).values(1, write));
  BOOST_RDB_CHECK_SELECT_RESULTS(db.execute(select(t.id, t.val).from(t)), "((1 03:11:17))");
}
Esempio n. 3
0
void mysql_statement::prepare(const sql &s)
{
  reset();
  
  str(s.prepare());
  // parse sql to create result and host arrays
  result_size = s.result_size();
  host_size = s.host_size();
  if (host_size) {
    host_array = new MYSQL_BIND[host_size];
    memset(host_array, 0, host_size * sizeof(MYSQL_BIND));
    length_vector.assign(host_size, 0);
  }
  
  int res = mysql_stmt_prepare(stmt, str().c_str(), str().size());
  if (res > 0) {
    throw_stmt_error(res, stmt, "mysql", str());
  }
}
Esempio n. 4
0
void sqlite_statement::prepare(const sql &s)
{
  reset();
  
  str(s.prepare());

  // destroy statement
  clear();
  // prepare sqlite statement
  int ret = sqlite3_prepare_v2(db_(), str().c_str(), str().size(), &stmt_, 0);
  throw_error(ret, db_(), "sqlite3_prepare_v2", str());
}
Esempio n. 5
0
BOOST_FIXTURE_TEST_CASE(test_time_bind_varchar, fixture) {

  using sql::select;

  test1 t;

  varchar<30> write = "03:11:17";
  db.prepare(insert_into(t)(t.id, t.val).values(1, _)).bind_parameters(write).execute();

  varchar<30> read;
  db.prepare(select(t.val).from(t)).bind_results(read).execute().fetch();
  BOOST_CHECK(!read.is_null());
  BOOST_CHECK_EQUAL(read.value(), "03:11:17");
}
Esempio n. 6
0
BOOST_FIXTURE_TEST_CASE(test_time_bind_time, fixture) {

  using sql::select;

  test1 t;
  
  odbc::time write(3, 11, 17);
  db.prepare(insert_into(t)(t.id, t.val).values(1, _)).bind_parameters(write).execute();

  odbc::time read;
  db.prepare(select(t.val).from(t)).bind_results(read).execute().fetch();
  
  BOOST_CHECK(!read.is_null());
  BOOST_CHECK_EQUAL(read.value().hour, 3);
  BOOST_CHECK_EQUAL(read.value().minute, 11);
  BOOST_CHECK_EQUAL(read.value().second, 17);
}
Esempio n. 7
0
 virtual void write_expression(sql &cmd) const override  { cmd.write_evaluation(_delegate.only_column()); }
Esempio n. 8
0
void
exprn_mapper_base::write_expression(sql &cmd) const {
    assert(cmd.alias_is_wanted(id()));  // if this fails then I haven't thought through the optimization properly
    _expressionist->write_expression(cmd);
}
Esempio n. 9
0
 virtual void
 write_expression(sql &cmd) const override {
     cmd.write_cast(_arg.only_column(), (cmd.get_database().*_ctf)());
 }
Esempio n. 10
0
 virtual void write_expression(sql &cmd) const override  { cmd.write_prefix_exprn(_op, _operand.only_column()); }
Esempio n. 11
0
 virtual void write_expression(sql &cmd) const override  { cmd.write_infix_exprn(_lhs.only_column(), _op, _rhs.only_column()); }
Esempio n. 12
0
void
table_base::write_table_reference(sql &cmd) const {
    if (!_is_open)  throw table_closed_exception();

    cmd.write_quoted(_binomen);
}
Esempio n. 13
0
 virtual void write_expression(sql &cmd) const override  { cmd.write_scalar_subquery(_query); }