diff --git a/include/sqlpp11/cte.h b/include/sqlpp11/cte.h index fb84e3c7..7920a35b 100644 --- a/include/sqlpp11/cte.h +++ b/include/sqlpp11/cte.h @@ -27,6 +27,7 @@ #ifndef SQLPP_CTE_H #define SQLPP_CTE_H +#include #include #include #include @@ -37,6 +38,60 @@ namespace sqlpp { + template + struct cte_t; + + template + struct cte_column_spec_t + { + using _alias_t = typename FieldSpec::_alias_t; + + using _traits = make_traits, + tag::must_not_insert, + tag::must_not_update, + tag_if::value> + >; + }; + + template + struct make_cte_impl + { + using type = void; + }; + + template + struct make_cte_impl> + { + using type = cte_t...>; + }; + + template + using make_cte_t = typename make_cte_impl>::type; + + template + struct cte_t: public member_t>... // FIXME + { + using _alias_t = typename AliasProvider::_alias_t; + + Statement _statement; + }; + + template + struct serializer_t> + { + using _serialize_check = serialize_check_of; + using T = cte_t; + + static Context& _(const T& t, Context& context) + { + context << name_of::char_ptr() << " AS ("; + serialize(t._statement, context); + context << ")"; + return context; + } + }; + + // The cte is displayed as AliasProviderName except within the with: // - the with needs the // AliasProviderName AS (ColumnNames) (select/union) @@ -46,7 +101,7 @@ namespace sqlpp { template auto as(Statement statement) - -> cte + -> make_cte_t { // FIXME: Need to check stuff here. return { statement }; diff --git a/include/sqlpp11/result_row.h b/include/sqlpp11/result_row.h index 628edc76..67574354 100644 --- a/include/sqlpp11/result_row.h +++ b/include/sqlpp11/result_row.h @@ -28,6 +28,7 @@ #define SQLPP_RESULT_ROW_H #include +#include #include #include #include diff --git a/include/sqlpp11/result_row_fwd.h b/include/sqlpp11/result_row_fwd.h new file mode 100644 index 00000000..8df5b4ed --- /dev/null +++ b/include/sqlpp11/result_row_fwd.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013-2014, Roland Bock + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SQLPP_RESULT_ROW_FWD_H +#define SQLPP_RESULT_ROW_FWD_H + +namespace sqlpp +{ + template + struct result_row_t; + + template + struct dynamic_result_row_t; +} + +#endif diff --git a/include/sqlpp11/select_pseudo_table.h b/include/sqlpp11/select_pseudo_table.h index 7e50d87a..c4dbd3b4 100644 --- a/include/sqlpp11/select_pseudo_table.h +++ b/include/sqlpp11/select_pseudo_table.h @@ -31,6 +31,8 @@ namespace sqlpp { + // FIXME: We might use field specs here (same as with cte) + // // provide type information for sub-selects that are used as named expressions or tables template struct select_column_spec_t diff --git a/include/sqlpp11/with.h b/include/sqlpp11/with.h index 4811c8d7..8700641c 100644 --- a/include/sqlpp11/with.h +++ b/include/sqlpp11/with.h @@ -37,6 +37,9 @@ #include #include + +#include + namespace sqlpp { template