MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / execute

Method execute

graphlite/src/catalog/providers/schema.rs:490–634  ·  view source on GitHub ↗
(&mut self, op: CatalogOperation)

Source from the content-addressed store, hash-verified

488 }
489
490 fn execute(&mut self, op: CatalogOperation) -> CatalogResult<CatalogResponse> {
491 match op {
492 CatalogOperation::Create {
493 entity_type,
494 name,
495 params,
496 } => {
497 match entity_type {
498 EntityType::Schema => {
499 // Check if schema already exists and handle IF NOT EXISTS
500 let if_not_exists = params
501 .get("if_not_exists")
502 .and_then(|v| v.as_bool())
503 .unwrap_or(false);
504
505 if self.schemas.contains_key(&name) {
506 if if_not_exists {
507 // Schema exists but IF NOT EXISTS was specified, so succeed silently
508 Ok(CatalogResponse::Success {
509 data: Some(
510 json!({ "message": format!("Schema '{}' already exists", name) }),
511 ),
512 })
513 } else {
514 // Schema exists and no IF NOT EXISTS, return error
515 Err(CatalogError::DuplicateEntry(format!(
516 "Schema '{}' already exists",
517 name
518 )))
519 }
520 } else {
521 // Schema doesn't exist, create it
522 let schema = Schema::from_params(name.clone(), &params);
523 self.add_schema(schema)?;
524 Ok(CatalogResponse::Success {
525 data: Some(
526 json!({ "message": format!("Schema '{}' created", name) }),
527 ),
528 })
529 }
530 }
531 _ => Ok(CatalogResponse::NotSupported),
532 }
533 }
534
535 CatalogOperation::Drop {
536 entity_type,
537 name,
538 cascade,
539 } => match entity_type {
540 EntityType::Schema => {
541 let removed = self.remove_schema(&name, cascade)?;
542 Ok(CatalogResponse::Success {
543 data: Some(serde_json::to_value(removed)?),
544 })
545 }
546 _ => Ok(CatalogResponse::NotSupported),
547 },

Callers 3

test_schema_propertiesFunction · 0.45

Calls 12

cloneMethod · 0.80
add_schemaMethod · 0.80
remove_schemaMethod · 0.80
get_schemaMethod · 0.80
get_default_schemaMethod · 0.80
update_schemaMethod · 0.80
set_default_schemaMethod · 0.80
list_schemas_filteredMethod · 0.80
getMethod · 0.45
contains_keyMethod · 0.45
as_strMethod · 0.45
iterMethod · 0.45

Tested by 3

test_schema_propertiesFunction · 0.36