Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:42

0001 //
0002 // Copyright (c) 2019-2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 
0008 #ifndef BOOST_MYSQL_IMPL_META_CHECK_CONTEXT_IPP
0009 #define BOOST_MYSQL_IMPL_META_CHECK_CONTEXT_IPP
0010 
0011 #pragma once
0012 
0013 #include <boost/mysql/detail/typing/meta_check_context.hpp>
0014 
0015 void boost::mysql::detail::meta_check_context::add_field_absent_error()
0016 {
0017     auto& stream = add_error();
0018     stream << "Field ";
0019     insert_field_name(stream);
0020     if (has_field_names(name_table_))
0021     {
0022         stream << " is not present in the data returned by the server";
0023     }
0024     else
0025     {
0026         stream << " can't be mapped: there are more fields in your C++ data type than in your query";
0027     }
0028 }
0029 
0030 void boost::mysql::detail::meta_check_context::add_type_mismatch_error(const char* cpp_type_name)
0031 {
0032     auto& stream = add_error();
0033     stream << "Incompatible types for field ";
0034     insert_field_name(stream);
0035     stream << ": C++ type '" << cpp_type_name << "' is not compatible with DB type '"
0036            << column_type_to_str(current_meta()) << "'";
0037 }
0038 
0039 void boost::mysql::detail::meta_check_context::add_nullability_error()
0040 {
0041     auto& stream = add_error();
0042     stream << "NULL checks failed for field ";
0043     insert_field_name(stream);
0044     stream << ": the database type may be NULL, but the C++ type cannot. Use std::optional<T> or "
0045               "boost::optional<T>";
0046 }
0047 
0048 boost::mysql::error_code boost::mysql::detail::meta_check_context::check_errors(diagnostics& diag) const
0049 {
0050     if (errors_ != nullptr)
0051     {
0052         access::get_impl(diag).assign_client(errors_->str());
0053         return client_errc::metadata_check_failed;
0054     }
0055     return error_code();
0056 }
0057 
0058 #endif