#include <sqlpp/field.hpp>
#include <sqlpp/table.hpp>
#include <sqlpp/database.hpp>
namespace sqlpp{
field::field(
table_shared_ptr table_,
string_const_reference name_,
string_const_reference type_,
bool not_null_
)
:
properties::table_property(table_),
properties::name_property(name_),
m_not_null(not_null_)
{
m_type = data_type::from_string( type_ );
};
field::field(
table_shared_ptr table_,
string_const_reference name_,
data_type const& type_,
bool not_null_
)
:
properties::table_property(table_),
properties::name_property(name_),
m_type(type_),
m_not_null(not_null_)
{};
string_type field::get_create_statement() const
{
std::ostringstream out;
out<<"\t"<<get_name()<<" "<<m_type.get_sql();
if (is_not_null())
out<<" NOT NULL";
return out.str();
};
void field::set_type( string_const_reference type_)
{
m_type = data_type::from_string( type_ );
}
void field::set_type( data_type const& type_)
{
m_type = type_;
}
data_type const& field::get_type() const
{ return m_type;};
bool field::is_not_null() const
{ return m_not_null;};
void field::set_not_null( bool not_null_ )
{ m_not_null = not_null_;};
};