removed the value field from attribute_definition because it's a definition and should not hold a value.
This commit is contained in:
@@ -22,42 +22,44 @@ attribute_definition::attribute_definition(std::string name,
|
||||
, table_(std::move(table_name))
|
||||
, index_(0)
|
||||
, attributes_(attr)
|
||||
, value_(type, attr.size()) {
|
||||
, type_(type){
|
||||
}
|
||||
|
||||
attribute_definition::attribute_definition(std::string name, const utils::basic_type type,
|
||||
const utils::field_attributes &attr, const null_option null_opt,
|
||||
const size_t index)
|
||||
attribute_definition::attribute_definition(std::string name,
|
||||
const utils::basic_type type,
|
||||
const utils::field_attributes &attr,
|
||||
const null_option null_opt,
|
||||
const int index)
|
||||
: name_(std::move(name))
|
||||
, index_(index)
|
||||
, attributes_(attr)
|
||||
, null_option_(null_opt)
|
||||
, value_(type, attr.size()) {
|
||||
, type_(type) {
|
||||
}
|
||||
|
||||
attribute_definition::attribute_definition(std::string name,
|
||||
std::string table_name,
|
||||
const utils::basic_type type,
|
||||
const utils::field_attributes &attr, const null_option null_opt,
|
||||
const size_t index)
|
||||
const int index)
|
||||
: name_(std::move(name))
|
||||
, table_(std::move(table_name))
|
||||
, index_(index)
|
||||
, attributes_(attr)
|
||||
, null_option_(null_opt)
|
||||
, value_(type, attr.size()) {
|
||||
, type_(type) {
|
||||
}
|
||||
|
||||
attribute_definition::attribute_definition(std::string name,
|
||||
const utils::basic_type type,
|
||||
const size_t index,
|
||||
const int index,
|
||||
const std::shared_ptr<attribute_definition> &ref_column,
|
||||
const utils::field_attributes &attr, const null_option null_opt)
|
||||
: name_(std::move(name))
|
||||
, index_(index)
|
||||
, attributes_(attr)
|
||||
, null_option_(null_opt)
|
||||
, value_(type, attr.size())
|
||||
, type_(type)
|
||||
, reference_column_(ref_column) {
|
||||
}
|
||||
|
||||
@@ -98,7 +100,12 @@ bool attribute_definition::is_nullable() const {
|
||||
}
|
||||
|
||||
utils::basic_type attribute_definition::type() const {
|
||||
return value_.type();
|
||||
return type_;
|
||||
}
|
||||
|
||||
void attribute_definition::change_type(const utils::basic_type type, const utils::field_attributes& attr) {
|
||||
attributes_ = attr;
|
||||
type_ = type;
|
||||
}
|
||||
|
||||
std::shared_ptr<attribute_definition> attribute_definition::reference_column() const {
|
||||
@@ -110,52 +117,39 @@ bool attribute_definition::is_foreign_reference() const {
|
||||
}
|
||||
|
||||
bool attribute_definition::is_integer() const {
|
||||
return value_.is_integer();
|
||||
return type_ >= utils::basic_type::type_int8 && type_ <= utils::basic_type::type_uint64;
|
||||
}
|
||||
|
||||
bool attribute_definition::is_floating_point() const {
|
||||
return value_.is_floating_point();
|
||||
return type_ == utils::basic_type::type_float || type_ == utils::basic_type::type_double;
|
||||
}
|
||||
|
||||
bool attribute_definition::is_bool() const {
|
||||
return value_.is_bool();
|
||||
return type_ == utils::basic_type::type_bool;
|
||||
}
|
||||
|
||||
bool attribute_definition::is_string() const {
|
||||
return value_.is_string();
|
||||
return type_ == utils::basic_type::type_text;
|
||||
}
|
||||
|
||||
bool attribute_definition::is_varchar() const {
|
||||
return value_.is_varchar();
|
||||
return type_ == utils::basic_type::type_varchar;
|
||||
}
|
||||
|
||||
bool attribute_definition::is_date() const {
|
||||
return value_.is_date();
|
||||
return type_ == utils::basic_type::type_date;
|
||||
}
|
||||
|
||||
bool attribute_definition::is_time() const {
|
||||
return value_.is_time();
|
||||
return type_ == utils::basic_type::type_time;
|
||||
}
|
||||
|
||||
bool attribute_definition::is_blob() const {
|
||||
return value_.is_blob();
|
||||
return type_ == utils::basic_type::type_blob;
|
||||
}
|
||||
|
||||
bool attribute_definition::is_null() const {
|
||||
return value_.is_null();
|
||||
}
|
||||
|
||||
void attribute_definition::type(const utils::basic_type type) {
|
||||
value_.type(type);
|
||||
}
|
||||
|
||||
std::string attribute_definition::str() const {
|
||||
return value_.str();
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const attribute_definition &col) {
|
||||
out << col.str();
|
||||
return out;
|
||||
return type_ == utils::basic_type::type_null;
|
||||
}
|
||||
|
||||
attribute_definition make_column(const std::string &name, utils::basic_type type, utils::field_attributes attr,
|
||||
|
||||
@@ -112,7 +112,7 @@ std::shared_ptr<attribute_definition> repository_node::determine_reference_colum
|
||||
tree.missing_references_.erase(it);
|
||||
ref_column->name(pk_info.pk_column_name);
|
||||
ref_column->table_name(name);
|
||||
ref_column->type(pk_info.type);
|
||||
ref_column->change_type(pk_info.type);
|
||||
ref_column->attributes() = utils::constraints::FOREIGN_KEY;
|
||||
|
||||
if (name.empty()) {
|
||||
|
||||
@@ -7,18 +7,15 @@ namespace detail {
|
||||
|
||||
void initialize_by_basic_type(basic_type type, database_type &val);
|
||||
|
||||
size_t determine_size(const std::string &val)
|
||||
{
|
||||
size_t determine_size(const std::string &val) {
|
||||
return val.size();
|
||||
}
|
||||
|
||||
size_t determine_size(const char *val)
|
||||
{
|
||||
size_t determine_size(const char *val) {
|
||||
return strlen(val);
|
||||
}
|
||||
|
||||
size_t determine_size(const blob &val)
|
||||
{
|
||||
size_t determine_size(const blob &val) {
|
||||
return val.size();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user