diff --git a/README.md b/README.md index 4ff58a31..d2915bb1 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ sqlpp11 A type safe embedded domain specific language for SQL queries and results in C++ +Extensive documentation is found in the wiki, https://github.com/rbock/sqlpp11/wiki Motivation: ----------- @@ -92,7 +93,9 @@ __Compiler:__ sqlpp11 makes heavy use of C++11 and requires a recent compiler and STL. The following compilers are known to compile the test programs: * clang-3.2 on Ubuntu-12.4 + * clang-3.4 on Ubuntu-12.4 * g++-4.8 on Ubuntu-12.4 + * g++-4.9 on Debian Unstable __Database Connector:__ sqlpp11 requires a certain api in order to connect with the database, see database/api.h. @@ -100,4 +103,7 @@ sqlpp11 requires a certain api in order to connect with the database, see databa * MySQL: https://github.com/rbock/sqlpp11-connector-mysql * Sqlite3: https://github.com/rbock/sqlpp11-connector-sqlite3 * PostgreSQL: https://github.com/matthijs/sqlpp11-connector-postgresql + +To demonstrate that sqlpp11 can work with other backends as well, here is an experimental backend for structs in standard containers: + * STL Container: https://github.com/rbock/sqlpp11-connector-stl diff --git a/include/sqlpp11/text.h b/include/sqlpp11/text.h index 6cce5aea..9fff0b77 100644 --- a/include/sqlpp11/text.h +++ b/include/sqlpp11/text.h @@ -216,6 +216,7 @@ namespace sqlpp } using text = detail::text; + using blob = detail::text; using varchar = detail::text; using char_ = detail::text; diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index 13011825..e65cf233 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -93,6 +93,10 @@ types = { 'char': 'char_', 'varchar': 'varchar', 'text': 'text', + 'tinyblob': 'blob', + 'blob': 'blob', + 'mediumblob': 'blob', + 'longblob': 'blob', 'bool': 'boolean', 'double': 'floating_point', 'float': 'floating_point', diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b7109ae7..13942a11 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,11 +16,11 @@ build_and_run(FunctionTest) build_and_run(PreparedTest) build_and_run(Minimalistic) -find_package(PythonInterp REQUIRED) - -add_custom_command( - OUTPUT ${CMAKE_CURRENT_LIST_DIR}/Sample.h - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/ddl2cpp ${CMAKE_CURRENT_LIST_DIR}/sample.sql Sample test - DEPENDS ${CMAKE_CURRENT_LIST_DIR}/sample.sql - ) +# if you want to use the generator, you can do something like this: +#find_package(PythonInterp REQUIRED) +#add_custom_command( +# OUTPUT ${CMAKE_CURRENT_LIST_DIR}/Sample.h +# COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/ddl2cpp ${CMAKE_CURRENT_LIST_DIR}/sample.sql Sample test +# DEPENDS ${CMAKE_CURRENT_LIST_DIR}/sample.sql +# ) diff --git a/tests/Sample.h b/tests/Sample.h new file mode 100644 index 00000000..33eb36e0 --- /dev/null +++ b/tests/Sample.h @@ -0,0 +1,190 @@ +#ifndef TEST_SAMPLE_H +#define TEST_SAMPLE_H + +#include +#include + +namespace test +{ + namespace TabFoo_ + { + struct Delta + { + struct _name_t + { + static constexpr const char* _get_name() { return "delta"; } + template + struct _member_t + { + T delta; + T& operator()() { return delta; } + const T& operator()() const { return delta; } + }; + }; + using _value_type = sqlpp::varchar; + struct _column_type + { + using _can_be_null = std::true_type; + }; + }; + struct Epsilon + { + struct _name_t + { + static constexpr const char* _get_name() { return "epsilon"; } + template + struct _member_t + { + T epsilon; + T& operator()() { return epsilon; } + const T& operator()() const { return epsilon; } + }; + }; + using _value_type = sqlpp::bigint; + struct _column_type + { + using _can_be_null = std::true_type; + }; + }; + struct Omega + { + struct _name_t + { + static constexpr const char* _get_name() { return "omega"; } + template + struct _member_t + { + T omega; + T& operator()() { return omega; } + const T& operator()() const { return omega; } + }; + }; + using _value_type = sqlpp::floating_point; + struct _column_type + { + using _can_be_null = std::true_type; + }; + }; + } + + struct TabFoo: sqlpp::table_t + { + using _value_type = sqlpp::no_value_t; + struct _name_t + { + static constexpr const char* _get_name() { return "tab_foo"; } + template + struct _member_t + { + T tabFoo; + T& operator()() { return tabFoo; } + const T& operator()() const { return tabFoo; } + }; + }; + }; + namespace TabBar_ + { + struct Alpha + { + struct _name_t + { + static constexpr const char* _get_name() { return "alpha"; } + template + struct _member_t + { + T alpha; + T& operator()() { return alpha; } + const T& operator()() const { return alpha; } + }; + }; + using _value_type = sqlpp::bigint; + struct _column_type + { + using _must_not_insert = std::true_type; + using _must_not_update = std::true_type; + using _can_be_null = std::true_type; + }; + }; + struct Beta + { + struct _name_t + { + static constexpr const char* _get_name() { return "beta"; } + template + struct _member_t + { + T beta; + T& operator()() { return beta; } + const T& operator()() const { return beta; } + }; + }; + using _value_type = sqlpp::varchar; + struct _column_type + { + using _can_be_null = std::true_type; + }; + }; + struct Gamma + { + struct _name_t + { + static constexpr const char* _get_name() { return "gamma"; } + template + struct _member_t + { + T gamma; + T& operator()() { return gamma; } + const T& operator()() const { return gamma; } + }; + }; + using _value_type = sqlpp::boolean; + struct _column_type + { + using _require_insert = std::true_type; + }; + }; + struct Delta + { + struct _name_t + { + static constexpr const char* _get_name() { return "delta"; } + template + struct _member_t + { + T delta; + T& operator()() { return delta; } + const T& operator()() const { return delta; } + }; + }; + using _value_type = sqlpp::integer; + struct _column_type + { + using _can_be_null = std::true_type; + }; + }; + } + + struct TabBar: sqlpp::table_t + { + using _value_type = sqlpp::no_value_t; + struct _name_t + { + static constexpr const char* _get_name() { return "tab_bar"; } + template + struct _member_t + { + T tabBar; + T& operator()() { return tabBar; } + const T& operator()() const { return tabBar; } + }; + }; + }; +} +#endif