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/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}} }; } 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/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 }; } diff --git a/include/sqlpp11/table_alias.h b/include/sqlpp11/table_alias.h index 7cc58a9f..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) 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/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"); +} 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; }