Commit 69586acd authored by msobczak's avatar msobczak

Name fixes.

parent c0e93b36
......@@ -1069,50 +1069,50 @@ void test11()
// Support for soci Common Tests
//
struct TableCreator1 : public tests::table_creator_base
struct table_creator_1 : public tests::table_creator_base
{
TableCreator1(session& session)
: tests::table_creator_base(session)
table_creator_1(session & sql)
: tests::table_creator_base(sql)
{
session << "create table soci_test(id integer, val integer, c char, "
sql << "create table soci_test(id integer, val integer, c char, "
"str varchar(20), sh smallint, ul decimal(9,0), d double precision, "
"tm timestamp, i1 integer, i2 integer, i3 integer, name varchar(20))";
session.commit();
session.begin();
sql.commit();
sql.begin();
}
};
struct TableCreator2 : public tests::table_creator_base
struct table_creator_2 : public tests::table_creator_base
{
TableCreator2(session& session)
: tests::table_creator_base(session)
table_creator_2(session & sql)
: tests::table_creator_base(sql)
{
session << "create table soci_test(\"num_float\" float, \"num_int\" integer, "
sql << "create table soci_test(\"num_float\" float, \"num_int\" integer, "
"\"name\" varchar(20), \"sometime\" timestamp, \"chr\" char)";
session.commit();
session.begin();
sql.commit();
sql.begin();
}
};
struct TableCreator3 : public tests::table_creator_base
struct table_creator_3 : public tests::table_creator_base
{
TableCreator3(session& session)
: tests::table_creator_base(session)
table_creator_3(session & sql)
: tests::table_creator_base(sql)
{
// CommonTest uses lower-case column names,
// so we need to enforce such names here.
// That's why column names are enclosed in ""
session << "create table soci_test(\"name\" varchar(100) not null, "
sql << "create table soci_test(\"name\" varchar(100) not null, "
"\"phone\" varchar(15))";
session.commit();
session.begin();
sql.commit();
sql.begin();
}
};
class TestContext : public tests::test_context_base
class test_context : public tests::test_context_base
{
public:
TestContext(backend_factory const &backEnd,
test_context(backend_factory const &backEnd,
std::string const &connectString)
: test_context_base(backEnd, connectString)
{}
......@@ -1169,7 +1169,7 @@ int main(int argc, char** argv)
try
{
TestContext tc(backEnd, connectString);
test_context tc(backEnd, connectString);
tests::common_tests tests(tc);
tests.run();
......
......@@ -259,6 +259,6 @@ SOCI_MYSQL_DECL backend_factory const * factory_mysql();
} // extern "C"
} // namespace SOCI
} // namespace soci
#endif // SOCI_MYSQL_H_INCLUDED
......@@ -419,10 +419,10 @@ void test6()
// DDL Creation objects for common tests
struct table_creator_one : public table_creator_base
{
table_creator_one(session& session)
: table_creator_base(session)
table_creator_one(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(id integer, val integer, c char, "
sql << "create table soci_test(id integer, val integer, c char, "
"str varchar(20), sh int2, ul numeric(20), d float8, "
"tm datetime, i1 integer, i2 integer, i3 integer, "
"name varchar(20)) type=InnoDB";
......@@ -431,20 +431,20 @@ struct table_creator_one : public table_creator_base
struct table_creator_two : public table_creator_base
{
table_creator_two(session& session)
: table_creator_base(session)
table_creator_two(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(num_float float8, num_int integer,"
sql << "create table soci_test(num_float float8, num_int integer,"
" name varchar(20), sometime datetime, chr char)";
}
};
struct table_creator_three : public table_creator_base
{
table_creator_three(session& session)
: table_creator_base(session)
table_creator_three(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(name varchar(100) not null, "
sql << "create table soci_test(name varchar(100) not null, "
"phone varchar(15))";
}
};
......
......@@ -310,6 +310,6 @@ SOCI_ODBC_DECL backend_factory const * factory_odbc();
} // extern "C"
} // namespace SOCI
} // namespace soci
#endif // SOCI_EMPTY_H_INCLUDED
......@@ -30,14 +30,6 @@ void odbc_standard_into_type_backend::define_by_pos(
buf_ = new char[size];
data = buf_;
break;
case x_cstring:
{
details::cstring_descriptor *desc = static_cast<cstring_descriptor *>(data);
odbcType_ = SQL_C_CHAR;
data = desc->str_;
size = static_cast<SQLINTEGER>(desc->bufSize_);
}
break;
case x_stdstring:
odbcType_ = SQL_C_CHAR;
size = 32769;
......@@ -128,18 +120,6 @@ void odbc_standard_into_type_backend::post_fetch(
char *c = static_cast<char*>(data_);
*c = buf_[0];
}
if (type_ == x_cstring)
{
if (ind != NULL)
{
details::cstring_descriptor *desc = static_cast<cstring_descriptor *>(data_);
int size = static_cast<SQLINTEGER>(desc->bufSize_);
if (size < valueLen_)
{
*ind = i_truncated;
}
}
}
if (type_ == x_stdstring)
{
std::string *s = static_cast<std::string *>(data_);
......
......@@ -50,16 +50,6 @@ void odbc_standard_use_type_backend::prepare_for_bind(
data = buf_;
indHolder_ = SQL_NTS;
break;
case x_cstring:
{
details::cstring_descriptor *desc = static_cast<cstring_descriptor *>(data);
sqlType = SQL_VARCHAR;
cType = SQL_C_CHAR;
data = desc->str_;
size = static_cast<SQLUINTEGER>(desc->bufSize_);
indHolder_ = SQL_NTS;
}
break;
case x_stdstring:
{
// TODO: No textual value is assigned here!
......
......@@ -14,42 +14,42 @@
#include <ctime>
#include <cmath>
using namespace SOCI;
using namespace SOCI::tests;
using namespace soci;
using namespace soci::tests;
std::string connectString;
BackEndFactory const &backEnd = odbc;
backend_factory const &backEnd = odbc;
// DDL Creation objects for common tests
struct TableCreator1 : public TableCreatorBase
struct table_creator_1 : public table_creator_base
{
TableCreator1(Session& session)
: TableCreatorBase(session)
table_creator_1(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(id integer, val integer, c char, "
sql << "create table soci_test(id integer, val integer, c char, "
"str varchar(20), sh integer, ul number, d float, "
"tm timestamp, i1 integer, i2 integer, i3 integer, "
"name varchar(20))";
}
};
struct TableCreator2 : public TableCreatorBase
struct table_creator_2 : public table_creator_base
{
TableCreator2(Session& session)
: TableCreatorBase(session)
table_creator_2(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(num_float float, num_int integer,"
sql << "create table soci_test(num_float float, num_int integer,"
" name varchar(20), sometime datetime, chr char)";
}
};
struct TableCreator3 : public TableCreatorBase
struct table_creator_3 : public table_creator_base
{
TableCreator3(Session& session)
: TableCreatorBase(session)
table_creator_3(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(name varchar(100) not null, "
sql << "create table soci_test(name varchar(100) not null, "
"phone varchar(15))";
}
};
......@@ -58,26 +58,26 @@ struct TableCreator3 : public TableCreatorBase
// Support for SOCI Common Tests
//
class TestContext : public TestContextBase
class test_context : public test_context_base
{
public:
TestContext(BackEndFactory const &backEnd,
test_context(backend_factory const &backEnd,
std::string const &connectString)
: TestContextBase(backEnd, connectString) {}
: test_context_base(backEnd, connectString) {}
TableCreatorBase* tableCreator1(Session& s) const
table_creator_base * table_creator_1(session& s) const
{
return new TableCreator1(s);
return new table_creator_1(s);
}
TableCreatorBase* tableCreator2(Session& s) const
table_creator_base * table_creator_2(session& s) const
{
return new TableCreator2(s);
return new table_creator_2(s);
}
TableCreatorBase* tableCreator3(Session& s) const
table_creator_base * table_creator_3(session& s) const
{
return new TableCreator3(s);
return new table_creator_3(s);
}
std::string fromDual (std::string const &sql) const
......@@ -90,7 +90,7 @@ public:
return "#" + datdt_string + "#";
}
std::string toDateTime(std::string const &datdt_string) const
std::string to_date_time(std::string const &datdt_string) const
{
return "#" + datdt_string + "#";
}
......@@ -118,16 +118,16 @@ int main(int argc, char** argv)
}
try
{
TestContext tc(backEnd, connectString);
CommonTests tests(tc);
test_context tc(backEnd, connectString);
common_tests tests(tc);
tests.run();
}
catch (SOCI::ODBCSOCIError const & e)
catch (soci::odbc_soci_error const & e)
{
std::cout << "ODBC Error Code: " << e.odbcErrorCode() << std::endl
<< "Native Error Code: " << e.nativeErrorCode() << std::endl
std::cout << "ODBC Error Code: " << e.odbc_error_code() << std::endl
<< "Native Error Code: " << e.native_error_code() << std::endl
<< "SOCI Message: " << e.what() << std::endl
<< "ODBC Message: " << e.odbcErrorMessage() << std::endl;
<< "ODBC Message: " << e.odbc_error_message() << std::endl;
}
catch (std::exception const & e)
{
......
......@@ -22,34 +22,34 @@ backend_factory const &backEnd = odbc;
// DDL Creation objects for common tests
struct TableCreator1 : public table_creator_base
struct table_creator_one : public table_creator_base
{
TableCreator1(session& session)
: table_creator_base(session)
table_creator_one(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(id integer, val integer, c char, "
sql << "create table soci_test(id integer, val integer, c char, "
"str varchar(20), sh smallint, ul numeric(20), d float, "
"tm datetime, i1 integer, i2 integer, i3 integer, "
"name varchar(20))";
}
};
struct TableCreator2 : public table_creator_base
struct table_creator_two : public table_creator_base
{
TableCreator2(session& session)
: table_creator_base(session)
table_creator_two(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(num_float float, num_int integer,"
sql << "create table soci_test(num_float float, num_int integer,"
" name varchar(20), sometime datetime, chr char)";
}
};
struct TableCreator3 : public table_creator_base
struct table_creator_three : public table_creator_base
{
TableCreator3(session& session)
: table_creator_base(session)
table_creator_three(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(name varchar(100) not null, "
sql << "create table soci_test(name varchar(100) not null, "
"phone varchar(15))";
}
};
......@@ -58,26 +58,26 @@ struct TableCreator3 : public table_creator_base
// Support for SOCI Common Tests
//
class TestContext : public test_context_base
class test_context : public test_context_base
{
public:
TestContext(backend_factory const &backEnd,
test_context(backend_factory const &backEnd,
std::string const &connectString)
: test_context_base(backEnd, connectString) {}
table_creator_base* table_creator_1(session& s) const
{
return new TableCreator1(s);
return new table_creator_one(s);
}
table_creator_base* table_creator_2(session& s) const
{
return new TableCreator2(s);
return new table_creator_two(s);
}
table_creator_base* table_creator_3(session& s) const
{
return new TableCreator3(s);
return new table_creator_three(s);
}
std::string to_date_time(std::string const &datdt_string) const
......@@ -108,7 +108,7 @@ int main(int argc, char** argv)
}
try
{
TestContext tc(backEnd, connectString);
test_context tc(backEnd, connectString);
common_tests tests(tc);
tests.run();
std::cout << "\nOK, all tests passed.\n";
......
......@@ -112,7 +112,7 @@ int main(int argc, char** argv)
common_tests tests(tc);
tests.run();
}
catch (SOCI::odbc_soci_error const & e)
catch (soci::odbc_soci_error const & e)
{
std::cout << "ODBC Error Code: " << e.odbc_error_code() << std::endl
<< "Native Error Code: " << e.native_error_code() << std::endl
......
......@@ -113,7 +113,7 @@ int main(int argc, char** argv)
common_tests tests(tc);
tests.run();
}
catch (SOCI::odbc_soci_error const & e)
catch (soci::odbc_soci_error const & e)
{
std::cout << "ODBC Error Code: " << e.odbc_error_code() << std::endl
<< "Native Error Code: " << e.native_error_code() << std::endl
......
......@@ -11,7 +11,7 @@
#include "soci-backend.h"
#include <sstream>
namespace SOCI
namespace soci
{
inline void throw_odbc_error(SQLSMALLINT htype, SQLHANDLE hndl, char const * msg)
......
......@@ -133,9 +133,6 @@ void odbc_vector_into_type_backend::define_by_pos(
}
break;
case x_cstring: break; // not supported
// (there is no specialization
// of IntoType<vector<char*> >)
case x_statement: break; // not supported
case x_rowid: break; // not supported
case x_blob: break; // not supported
......@@ -312,7 +309,6 @@ void odbc_vector_into_type_backend::resize(std::size_t sz)
}
break;
case x_cstring: break; // not supported
case x_statement: break; // not supported
case x_rowid: break; // not supported
case x_blob: break; // not supported
......@@ -372,7 +368,6 @@ std::size_t odbc_vector_into_type_backend::size()
}
break;
case x_cstring: break; // not supported
case x_statement: break; // not supported
case x_rowid: break; // not supported
case x_blob: break; // not supported
......
......@@ -165,7 +165,6 @@ void odbc_vector_use_type_backend::prepare_for_bind(void *&data, SQLUINTEGER &si
case x_statement: break; // not supported
case x_rowid: break; // not supported
case x_blob: break; // not supported
case x_cstring: break; // not supported
}
colSize_ = size;
......@@ -366,7 +365,6 @@ std::size_t odbc_vector_use_type_backend::size()
case x_statement: break; // not supported
case x_rowid: break; // not supported
case x_blob: break; // not supported
case x_cstring: break; // not supported
}
return sz;
......
......@@ -152,7 +152,7 @@ oracle_session_backend::~oracle_session_backend()
void oracle_session_backend::begin()
{
// This code is commented out because it causes one of the transaction
// tests in CommonTests::test10() to fail with error 'Invalid handle'
// tests in common_tests::test10() to fail with error 'Invalid handle'
// With the code commented out, all tests pass.
// sword res = OCITransStart(svchp_, errhp_, 0, OCI_TRANS_NEW);
// if (res != OCI_SUCCESS)
......
......@@ -92,10 +92,10 @@ void test2()
struct blob_table_creator : public table_creator_base
{
blob_table_creator(session& session)
: table_creator_base(session)
blob_table_creator(session & sql)
: table_creator_base(sql)
{
session <<
sql <<
"create table soci_test ("
" id number(10) not null,"
" img blob"
......@@ -157,10 +157,10 @@ void test3()
struct basic_table_creator : public table_creator_base
{
basic_table_creator(session& session)
: table_creator_base(session)
basic_table_creator(session & sql)
: table_creator_base(sql)
{
session <<
sql <<
"create table soci_test ("
" id number(5) not null,"
" name varchar2(100),"
......@@ -232,10 +232,10 @@ void test5()
// Stored procedures
struct procedure_creator : procedure_creator_base
{
procedure_creator(session& session)
: procedure_creator_base(session)
procedure_creator(session & sql)
: procedure_creator_base(sql)
{
session <<
sql <<
"create or replace procedure soci_test(output out varchar2,"
"input in varchar2) as "
"begin output := input; end;";
......@@ -305,20 +305,20 @@ namespace soci
struct in_out_procedure_creator : public procedure_creator_base
{
in_out_procedure_creator(session& session)
: procedure_creator_base(session)
in_out_procedure_creator(session & sql)
: procedure_creator_base(sql)
{
session << "create or replace procedure soci_test(s in out varchar2)"
sql << "create or replace procedure soci_test(s in out varchar2)"
" as begin s := s || s; end;";
}
};
struct returns_null_procedure_creator : public procedure_creator_base
{
returns_null_procedure_creator(session& session)
: procedure_creator_base(session)
returns_null_procedure_creator(session & sql)
: procedure_creator_base(sql)
{
session << "create or replace procedure soci_test(s in out varchar2)"
sql << "create or replace procedure soci_test(s in out varchar2)"
" as begin s := NULL; end;";
}
};
......@@ -736,10 +736,10 @@ namespace soci
struct person_table_creator : public table_creator_base
{
person_table_creator(session& session)
: table_creator_base(session)
person_table_creator(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(id numeric(5,0) NOT NULL,"
sql << "create table soci_test(id numeric(5,0) NOT NULL,"
<< " last_name varchar2(20), first_name varchar2(20), "
" gender varchar2(10))";
}
......@@ -747,10 +747,10 @@ struct person_table_creator : public table_creator_base
struct times100_procedure_creator : public procedure_creator_base
{
times100_procedure_creator(session& session)
: procedure_creator_base(session)
times100_procedure_creator(session & sql)
: procedure_creator_base(sql)
{
session << "create or replace procedure soci_test(id in out number)"
sql << "create or replace procedure soci_test(id in out number)"
" as begin id := id * 100; end;";
}
};
......@@ -947,10 +947,10 @@ void test11()
///
struct long_table_creator : public table_creator_base
{
long_table_creator(session& session)
: table_creator_base(session)
long_table_creator(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(l long)";
sql << "create table soci_test(l long)";
}
};
......@@ -1065,10 +1065,10 @@ void test14()
struct table_creator_one : public table_creator_base
{
table_creator_one(session& session)
: table_creator_base(session)
table_creator_one(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(id number(10,0), val number(4,0), c char, "
sql << "create table soci_test(id number(10,0), val number(4,0), c char, "
"str varchar2(20), sh number, ul number, d number, "
"tm date, i1 number, i2 number, i3 number, name varchar2(20))";
}
......@@ -1076,20 +1076,20 @@ struct table_creator_one : public table_creator_base
struct table_creator_two : public table_creator_base
{
table_creator_two(session& session)
: table_creator_base(session)
table_creator_two(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(num_float number, num_int numeric(4,0),"
sql << "create table soci_test(num_float number, num_int numeric(4,0),"
" name varchar2(20), sometime date, chr char)";
}
};
struct table_creator_three : public table_creator_base
{
table_creator_three(session& session)
: table_creator_base(session)
table_creator_three(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(name varchar2(100) not null, "
sql << "create table soci_test(name varchar2(100) not null, "
"phone varchar2(15))";
}
};
......
......@@ -85,17 +85,17 @@ class function_creator : function_creator_base
{
public:
function_creator(session& session)
: function_creator_base(session)
function_creator(session & sql)
: function_creator_base(sql)
{
// before a language can be used it must be defined
// if it has already been defined then an error will occur
try { session << "create language plpgsql"; }
try { sql << "create language plpgsql"; }
catch (soci_error const &) {} // ignore if error
#ifndef SOCI_PGSQL_NOPARAMS
session <<
sql <<
"create or replace function soci_test(msg varchar) "
"returns varchar as $$ "
"begin "
......@@ -103,7 +103,7 @@ public:
"end $$ language plpgsql";
#else
session <<
sql <<
"create or replace function soci_test(varchar) "
"returns varchar as \' "
"begin "
......@@ -179,10 +179,10 @@ void test2()
// BLOB test
struct blob_table_creator : public table_creator_base
{
blob_table_creator(session& session)
: table_creator_base(session)
blob_table_creator(session & sql)
: table_creator_base(sql)
{
session <<
sql <<
"create table soci_test ("
" id integer,"
" img oid"
......@@ -412,10 +412,10 @@ void test9()
// DDL Creation objects for common tests
struct table_creator_one : public table_creator_base
{
table_creator_one(session& session)
: table_creator_base(session)
table_creator_one(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(id integer, val integer, c char, "
sql << "create table soci_test(id integer, val integer, c char, "
"str varchar(20), sh int2, ul numeric(20), d float8, "
"tm timestamp, i1 integer, i2 integer, i3 integer, "
"name varchar(20))";
......@@ -424,20 +424,20 @@ struct table_creator_one : public table_creator_base
struct table_creator_two : public table_creator_base
{
table_creator_two(session& session)
: table_creator_base(session)
table_creator_two(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(num_float float8, num_int integer,"
sql << "create table soci_test(num_float float8, num_int integer,"
" name varchar(20), sometime timestamp, chr char)";
}
};
struct table_creator_three : public table_creator_base
{
table_creator_three(session& session)
: table_creator_base(session)
table_creator_three(session & sql)
: table_creator_base(sql)
{
session << "create table soci_test(name varchar(100) not null, "
sql << "create table soci_test(name varchar(100) not null, "
"phone varchar(15))";
}