From 4974d136005ec9ab6f62e10e6ce5e514a8d0d678 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 21 Aug 2014 11:44:07 +0200 Subject: [PATCH 1/6] Fixed all_of(table_alias) --- include/sqlpp11/table_alias.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 7cc58a9f..821412f6 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -54,7 +54,7 @@ namespace sqlpp static_assert(required_tables_of::size::value == 0, "table aliases must not depend on external tables"); using _name_t = typename AliasProvider::_name_t; - using _column_tuple_t = std::tuple...>; + using _column_tuple_t = std::tuple...>; table_alias_t(Table table): _table(table) From a9339b54ad462462b837c3eeb8d6dad301bcf719 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 21 Aug 2014 13:00:40 +0200 Subject: [PATCH 2/6] Fixed all_of(alias_table) For real this time, I hope :-) --- include/sqlpp11/table_alias.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 821412f6..94ea6716 100644 --- a/include/sqlpp11/table_alias.h +++ b/include/sqlpp11/table_alias.h @@ -54,7 +54,7 @@ namespace sqlpp static_assert(required_tables_of
::size::value == 0, "table aliases must not depend on external tables"); using _name_t = typename AliasProvider::_name_t; - using _column_tuple_t = std::tuple...>; + using _column_tuple_t = std::tuple...>; table_alias_t(Table table): _table(table) From 10853abb0a8a03525c712087b8bf211752388366 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 21 Aug 2014 13:21:27 +0200 Subject: [PATCH 3/6] fixed static_assert message wording --- include/sqlpp11/column.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sqlpp11/column.h b/include/sqlpp11/column.h index 9f9a089a..1ecbeb73 100644 --- a/include/sqlpp11/column.h +++ b/include/sqlpp11/column.h @@ -90,7 +90,7 @@ namespace sqlpp auto operator =(T t) const -> assignment_t> { using rhs = wrap_operand_t; - static_assert(_is_valid_operand::value, "invalid rhs operand assignment operand"); + static_assert(_is_valid_operand::value, "invalid rhs assignment operand"); return { *this, {rhs{t}} }; } From 15c778844b7be6fa2a48262ca4d6152d265e5001 Mon Sep 17 00:00:00 2001 From: rbock Date: Thu, 21 Aug 2014 13:21:49 +0200 Subject: [PATCH 4/6] Added a few missing const qualifiers --- include/sqlpp11/basic_expression_operators.h | 6 +++--- include/sqlpp11/table.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/sqlpp11/basic_expression_operators.h b/include/sqlpp11/basic_expression_operators.h index fc54a876..7c7d3ec8 100644 --- a/include/sqlpp11/basic_expression_operators.h +++ b/include/sqlpp11/basic_expression_operators.h @@ -115,12 +115,12 @@ namespace sqlpp return { *static_cast(this) }; } - sort_order_t asc() + sort_order_t asc() const { return { *static_cast(this) }; } - sort_order_t desc() + sort_order_t desc() const { return { *static_cast(this) }; } @@ -145,7 +145,7 @@ namespace sqlpp struct alias_operators { template - expression_alias_t as(const alias_provider&) + expression_alias_t as(const alias_provider&) const { return { *static_cast(this) }; } diff --git a/include/sqlpp11/table.h b/include/sqlpp11/table.h index 52f747f3..06a1c2f5 100644 --- a/include/sqlpp11/table.h +++ b/include/sqlpp11/table.h @@ -62,31 +62,31 @@ namespace sqlpp template - join_t join(T t) + join_t join(T t) const { return { *static_cast(this), t }; } template - join_t inner_join(T t) + join_t inner_join(T t) const { return { *static_cast(this), t }; } template - join_t outer_join(T t) + join_t outer_join(T t) const { return { *static_cast(this), t }; } template - join_t left_outer_join(T t) + join_t left_outer_join(T t) const { return { *static_cast(this), t }; } template - join_t right_outer_join(T t) + join_t right_outer_join(T t) const { return { *static_cast(this), t }; } From fd054d8a5aa0440ab12cdb6501470588eb7f6afb Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 22 Aug 2014 12:26:48 +0200 Subject: [PATCH 5/6] Fixed operators += et al --- include/sqlpp11/integral.h | 8 ++++---- include/sqlpp11/text.h | 2 +- tests/MockDb.h | 4 ---- tests/UpdateTest.cpp | 2 ++ 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/sqlpp11/integral.h b/include/sqlpp11/integral.h index ecb9b14d..0e509bbf 100644 --- a/include/sqlpp11/integral.h +++ b/include/sqlpp11/integral.h @@ -205,7 +205,7 @@ namespace sqlpp using rhs = wrap_operand_t; static_assert(_is_valid_operand::value, "invalid rhs assignment operand"); - return { *static_cast(this), { *static_cast(this), rhs{t} } }; + return { *static_cast(this), {{*static_cast(this), rhs{t}}}}; } template @@ -214,7 +214,7 @@ namespace sqlpp using rhs = wrap_operand_t; static_assert(_is_valid_operand::value, "invalid rhs assignment operand"); - return { *static_cast(this), { *static_cast(this), rhs{t} } }; + return { *static_cast(this), {{*static_cast(this), rhs{t}}}}; } template @@ -223,7 +223,7 @@ namespace sqlpp using rhs = wrap_operand_t; static_assert(_is_valid_operand::value, "invalid rhs assignment operand"); - return { *static_cast(this), { *static_cast(this), rhs{t} } }; + return { *static_cast(this), {{*static_cast(this), rhs{t}}}}; } template @@ -232,7 +232,7 @@ namespace sqlpp using rhs = wrap_operand_t; static_assert(_is_valid_operand::value, "invalid rhs assignment operand"); - return { *static_cast(this), { *static_cast(this), rhs{t} } }; + return { *static_cast(this), {{*static_cast(this), rhs{t}}}}; } }; }; diff --git a/include/sqlpp11/text.h b/include/sqlpp11/text.h index d707d5a1..7dda39a8 100644 --- a/include/sqlpp11/text.h +++ b/include/sqlpp11/text.h @@ -150,7 +150,7 @@ namespace sqlpp using rhs = wrap_operand_t; static_assert(_is_valid_operand::value, "invalid rhs assignment operand"); - return { *static_cast(this), { *static_cast(this), rhs{t} } }; + return { *static_cast(this), concat_t>{ *static_cast(this), rhs{t} } }; } }; }; diff --git a/tests/MockDb.h b/tests/MockDb.h index 5ef1f110..0586c04c 100644 --- a/tests/MockDb.h +++ b/tests/MockDb.h @@ -165,8 +165,6 @@ struct MockDbT: public sqlpp::connection template size_t run_prepared_insert(const PreparedInsert& x) { - _serializer_context_t context; - ::sqlpp::serialize(x, context); return 0; } @@ -181,8 +179,6 @@ struct MockDbT: public sqlpp::connection template result_t run_prepared_select(PreparedSelect& x) { - _serializer_context_t context; - ::sqlpp::serialize(x, context); return {}; } diff --git a/tests/UpdateTest.cpp b/tests/UpdateTest.cpp index 04f73024..e12224ec 100644 --- a/tests/UpdateTest.cpp +++ b/tests/UpdateTest.cpp @@ -68,6 +68,8 @@ int main() db(update(t).set(t.delta = sqlpp::null).where(true)); db(update(t).set(t.delta = sqlpp::default_value).where(true)); + db(update(t).set(t.delta += t.alpha * 2, t.beta += " and cake").where(true)); + return 0; } From 404a8301a919664a3c7b367cd91376549f73c8ed Mon Sep 17 00:00:00 2001 From: rbock Date: Fri, 22 Aug 2014 22:18:04 +0200 Subject: [PATCH 6/6] Added missing file --- test_constraints/must_not_update.cpp | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test_constraints/must_not_update.cpp diff --git a/test_constraints/must_not_update.cpp b/test_constraints/must_not_update.cpp new file mode 100644 index 00000000..42f9ac04 --- /dev/null +++ b/test_constraints/must_not_update.cpp @@ -0,0 +1,37 @@ +/* + * 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. + */ + +#include "Sample.h" +#include "MockDb.h" +#include + +MockDb db; + +int main() +{ + test::TabBar t; + + update(t).set(t.alpha = 7, t.gamma = false, t.beta = "alpha must not be set"); +}