Fix naming for schemaproperty type to schema type
This commit is contained in:
parent
8eb136bc82
commit
7f81fda1c6
@ -14,6 +14,6 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace memgraph::common {
|
namespace memgraph::common {
|
||||||
enum class SchemaPropertyType : uint8_t { BOOL, INT, FLOAT, STRING, DATE, LOCALTIME, LOCALDATETIME, DURATION };
|
enum class SchemaType : uint8_t { BOOL, INT, FLOAT, STRING, DATE, LOCALTIME, LOCALDATETIME, DURATION };
|
||||||
|
|
||||||
} // namespace memgraph::common
|
} // namespace memgraph::common
|
||||||
|
@ -2677,7 +2677,7 @@ cpp<#
|
|||||||
#>cpp
|
#>cpp
|
||||||
${dest} = storage->GetLabelIx(${source}.name);
|
${dest} = storage->GetLabelIx(${source}.name);
|
||||||
cpp<#))
|
cpp<#))
|
||||||
(schema_property_map "std::unordered_map<PropertyIx, common::SchemaPropertyType>"
|
(schema_type_map "std::unordered_map<PropertyIx, common::SchemaType>"
|
||||||
:slk-save #'slk-save-property-map
|
:slk-save #'slk-save-property-map
|
||||||
:slk-load #'slk-load-property-map
|
:slk-load #'slk-load-property-map
|
||||||
:scope :public))
|
:scope :public))
|
||||||
@ -2686,9 +2686,6 @@ cpp<#
|
|||||||
(lcp:define-enum action
|
(lcp:define-enum action
|
||||||
(create-schema drop-schema show-schema show-schemas)
|
(create-schema drop-schema show-schema show-schemas)
|
||||||
(:serialize))
|
(:serialize))
|
||||||
(lcp:define-enum schema-type
|
|
||||||
(bool integer float string duration date localtime localdatetime)
|
|
||||||
(:serialize))
|
|
||||||
#>cpp
|
#>cpp
|
||||||
SchemaQuery() = default;
|
SchemaQuery() = default;
|
||||||
|
|
||||||
|
@ -2365,34 +2365,31 @@ antlrcpp::Any CypherMainVisitor::visitCreateSchema(MemgraphCypher::CreateSchemaC
|
|||||||
auto *schema_query = storage_->Create<SchemaQuery>();
|
auto *schema_query = storage_->Create<SchemaQuery>();
|
||||||
schema_query->action_ = SchemaQuery::Action::CREATE_SCHEMA;
|
schema_query->action_ = SchemaQuery::Action::CREATE_SCHEMA;
|
||||||
schema_query->label_ = AddLabel(ctx->labelName()->accept(this));
|
schema_query->label_ = AddLabel(ctx->labelName()->accept(this));
|
||||||
if (!ctx->schemaPropertyMap()) {
|
if (!ctx->schemaTypeMap()) {
|
||||||
throw SemanticException("Schema property map must exist!");
|
throw SemanticException("Schema property map must exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<PropertyIx, common::SchemaPropertyType> schema_property_map;
|
std::unordered_map<PropertyIx, common::SchemaType> schema_property_map;
|
||||||
// for (auto *property_pair : ctx->schemaPropertyMap()->propertyKeyTypePair()) {
|
for (auto *property_pair : ctx->schemaTypeMap()->propertyKeyTypePair()) {
|
||||||
// if (property_pair->propertyType()->getAltNumber()) {
|
if (property_pair->propertyType()) {
|
||||||
// schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaPropertyType::BOOL});
|
schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaType::BOOL});
|
||||||
// } else if (property_pair->propertyType()->STRING()) {
|
} else if (property_pair->propertyType()->STRING()) {
|
||||||
// schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaPropertyType::STRING});
|
schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaType::STRING});
|
||||||
// } else if (property_pair->propertyType()->INTEGER()) {
|
} else if (property_pair->propertyType()->INTEGER()) {
|
||||||
// schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaPropertyType::INT});
|
schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaType::INT});
|
||||||
// } else if (property_pair->propertyType()->FLOAT()) {
|
} else if (property_pair->propertyType()->FLOAT()) {
|
||||||
// schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaPropertyType::FLOAT});
|
schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaType::FLOAT});
|
||||||
// } else if (property_pair->propertyType()->DATE()) {
|
} else if (property_pair->propertyType()->DATE()) {
|
||||||
// schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaPropertyType::DATE});
|
schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaType::DATE});
|
||||||
// } else if (property_pair->propertyType()->DURATION()) {
|
} else if (property_pair->propertyType()->DURATION()) {
|
||||||
// schema_property_map.insert(
|
schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaType::DURATION});
|
||||||
// {property_pair->propertyKeyName()->accept(this), common::SchemaPropertyType::DURATION});
|
} else if (property_pair->propertyType()->LOCALDATETIME()) {
|
||||||
// } else if (property_pair->propertyType()->LOCALDATETIME()) {
|
schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaType::LOCALDATETIME});
|
||||||
// schema_property_map.insert(
|
} else if (property_pair->propertyType()->LOCALTIME()) {
|
||||||
// {property_pair->propertyKeyName()->accept(this), common::SchemaPropertyType::LOCALDATETIME});
|
schema_property_map.insert({property_pair->propertyKeyName()->accept(this), common::SchemaType::LOCALTIME});
|
||||||
// } else if (property_pair->propertyType()->LOCALTIME()) {
|
}
|
||||||
// schema_property_map.insert(
|
}
|
||||||
// {property_pair->propertyKeyName()->accept(this), common::SchemaPropertyType::LOCALTIME});
|
schema_query->schema_type_map_ = std::move(schema_property_map);
|
||||||
// }
|
|
||||||
// }
|
|
||||||
schema_query->schema_property_map_ = std::move(schema_property_map);
|
|
||||||
|
|
||||||
query_ = schema_query;
|
query_ = schema_query;
|
||||||
return schema_query;
|
return schema_query;
|
||||||
|
@ -401,8 +401,8 @@ propertyType : BOOL
|
|||||||
|
|
||||||
propertyKeyTypePair : propertyKeyName propertyType ;
|
propertyKeyTypePair : propertyKeyName propertyType ;
|
||||||
|
|
||||||
schemaPropertyMap : '(' ( propertyKeyTypePair ( ',' propertyKeyTypePair )* )? ')' ;
|
schemaTypeMap : '(' ( propertyKeyTypePair ( ',' propertyKeyTypePair )* )? ')' ;
|
||||||
|
|
||||||
createSchema : CREATE SCHEMA ON ':' labelName schemaPropertyMap ;
|
createSchema : CREATE SCHEMA ON ':' labelName schemaTypeMap ;
|
||||||
|
|
||||||
dropSchema : DROP SCHEMA ON ':' labelName ;
|
dropSchema : DROP SCHEMA ON ':' labelName ;
|
||||||
|
@ -853,7 +853,7 @@ Callback HandleSchemaQuery(SchemaQuery *schema_query, const Parameters ¶mete
|
|||||||
std::transform(schema_types.begin(), schema_types.end(), std::back_inserter(primary_key_properties),
|
std::transform(schema_types.begin(), schema_types.end(), std::back_inserter(primary_key_properties),
|
||||||
[&db](const auto &schema_type) {
|
[&db](const auto &schema_type) {
|
||||||
return db->PropertyToName(schema_type.property_id) +
|
return db->PropertyToName(schema_type.property_id) +
|
||||||
"::" + storage::SchemaPropertyToString(schema_type.type);
|
"::" + storage::SchemaTypeToString(schema_type.type);
|
||||||
});
|
});
|
||||||
|
|
||||||
schema_info_row.emplace_back(utils::Join(primary_key_properties, ", "));
|
schema_info_row.emplace_back(utils::Join(primary_key_properties, ", "));
|
||||||
@ -881,7 +881,7 @@ Callback HandleSchemaQuery(SchemaQuery *schema_query, const Parameters ¶mete
|
|||||||
schema_info_row.reserve(2);
|
schema_info_row.reserve(2);
|
||||||
|
|
||||||
schema_info_row.emplace_back(db->PropertyToName(schema_property.property_id));
|
schema_info_row.emplace_back(db->PropertyToName(schema_property.property_id));
|
||||||
schema_info_row.emplace_back(SchemaPropertyToString(schema_property.type));
|
schema_info_row.emplace_back(storage::SchemaTypeToString(schema_property.type));
|
||||||
|
|
||||||
results.push_back(std::move(schema_info_row));
|
results.push_back(std::move(schema_info_row));
|
||||||
}
|
}
|
||||||
@ -892,14 +892,14 @@ Callback HandleSchemaQuery(SchemaQuery *schema_query, const Parameters ¶mete
|
|||||||
}
|
}
|
||||||
case SchemaQuery::Action::CREATE_SCHEMA: {
|
case SchemaQuery::Action::CREATE_SCHEMA: {
|
||||||
callback.fn = [interpreter_context, schema_query]() {
|
callback.fn = [interpreter_context, schema_query]() {
|
||||||
// auto *db = interpreter_context->db;
|
auto *db = interpreter_context->db;
|
||||||
// const auto label = db->NameToLabel(schema_query->label_.name);
|
const auto label = db->NameToLabel(schema_query->label_.name);
|
||||||
// std::vector<storage::SchemaProperty> schemas_types;
|
std::vector<storage::SchemaProperty> schemas_types;
|
||||||
// for (const auto &schema_property : schema_query->properties_type_map_) {
|
// for (const auto &schema_property : schema_query->) {
|
||||||
// spdlog::info("sasa {}", db->PropertyToName(db->NameToProperty(schema_property.first.name)));
|
// spdlog::info("sasa {}", db->PropertyToName(db->NameToProperty(schema_property.first.name)));
|
||||||
// // schemas_types.emplace_back(db->NameToProperty(schema_property.first.name), schema_property.second);
|
// // schemas_types.emplace_back(db->NameToProperty(schema_property.first.name), schema_property.second);
|
||||||
// }
|
// }
|
||||||
// const auto res = db->CreateSchema(label, schemas_types);
|
// const auto res = db->CreateSchema(label, schemas_types);
|
||||||
return std::vector<std::vector<TypedValue>>{};
|
return std::vector<std::vector<TypedValue>>{};
|
||||||
};
|
};
|
||||||
return callback;
|
return callback;
|
||||||
|
@ -33,7 +33,7 @@ class SchemaViolationException : public utils::BasicException {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct SchemaProperty {
|
struct SchemaProperty {
|
||||||
common::SchemaPropertyType type;
|
common::SchemaType type;
|
||||||
PropertyId property_id;
|
PropertyId property_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -87,33 +87,33 @@ class Schemas {
|
|||||||
SchemasMap schemas_;
|
SchemasMap schemas_;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::optional<common::SchemaPropertyType> PropertyTypeToSchemaType(const PropertyValue &property_value) {
|
inline std::optional<common::SchemaType> PropertyTypeToSchemaType(const PropertyValue &property_value) {
|
||||||
switch (property_value.type()) {
|
switch (property_value.type()) {
|
||||||
case PropertyValue::Type::Bool: {
|
case PropertyValue::Type::Bool: {
|
||||||
return common::SchemaPropertyType::BOOL;
|
return common::SchemaType::BOOL;
|
||||||
}
|
}
|
||||||
case PropertyValue::Type::Int: {
|
case PropertyValue::Type::Int: {
|
||||||
return common::SchemaPropertyType::INT;
|
return common::SchemaType::INT;
|
||||||
}
|
}
|
||||||
case PropertyValue::Type::Double: {
|
case PropertyValue::Type::Double: {
|
||||||
return common::SchemaPropertyType::FLOAT;
|
return common::SchemaType::FLOAT;
|
||||||
}
|
}
|
||||||
case PropertyValue::Type::String: {
|
case PropertyValue::Type::String: {
|
||||||
return common::SchemaPropertyType::STRING;
|
return common::SchemaType::STRING;
|
||||||
}
|
}
|
||||||
case PropertyValue::Type::TemporalData: {
|
case PropertyValue::Type::TemporalData: {
|
||||||
switch (property_value.ValueTemporalData().type) {
|
switch (property_value.ValueTemporalData().type) {
|
||||||
case TemporalType::Date: {
|
case TemporalType::Date: {
|
||||||
return common::SchemaPropertyType::DATE;
|
return common::SchemaType::DATE;
|
||||||
}
|
}
|
||||||
case TemporalType::LocalDateTime: {
|
case TemporalType::LocalDateTime: {
|
||||||
return common::SchemaPropertyType::LOCALDATETIME;
|
return common::SchemaType::LOCALDATETIME;
|
||||||
}
|
}
|
||||||
case TemporalType::LocalTime: {
|
case TemporalType::LocalTime: {
|
||||||
return common::SchemaPropertyType::LOCALTIME;
|
return common::SchemaType::LOCALTIME;
|
||||||
}
|
}
|
||||||
case TemporalType::Duration: {
|
case TemporalType::Duration: {
|
||||||
return common::SchemaPropertyType::DURATION;
|
return common::SchemaType::DURATION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,30 +125,30 @@ inline std::optional<common::SchemaPropertyType> PropertyTypeToSchemaType(const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string SchemaPropertyToString(const common::SchemaPropertyType type) {
|
inline std::string SchemaTypeToString(const common::SchemaType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case common::SchemaPropertyType::BOOL: {
|
case common::SchemaType::BOOL: {
|
||||||
return "Bool";
|
return "Bool";
|
||||||
}
|
}
|
||||||
case common::SchemaPropertyType::INT: {
|
case common::SchemaType::INT: {
|
||||||
return "Integer";
|
return "Integer";
|
||||||
}
|
}
|
||||||
case common::SchemaPropertyType::FLOAT: {
|
case common::SchemaType::FLOAT: {
|
||||||
return "Float";
|
return "Float";
|
||||||
}
|
}
|
||||||
case common::SchemaPropertyType::STRING: {
|
case common::SchemaType::STRING: {
|
||||||
return "String";
|
return "String";
|
||||||
}
|
}
|
||||||
case common::SchemaPropertyType::DATE: {
|
case common::SchemaType::DATE: {
|
||||||
return "Date";
|
return "Date";
|
||||||
}
|
}
|
||||||
case common::SchemaPropertyType::LOCALTIME: {
|
case common::SchemaType::LOCALTIME: {
|
||||||
return "LocalTime";
|
return "LocalTime";
|
||||||
}
|
}
|
||||||
case common::SchemaPropertyType::LOCALDATETIME: {
|
case common::SchemaType::LOCALDATETIME: {
|
||||||
return "LocalDateTime";
|
return "LocalDateTime";
|
||||||
}
|
}
|
||||||
case common::SchemaPropertyType::DURATION: {
|
case common::SchemaType::DURATION: {
|
||||||
return "Duration";
|
return "Duration";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user