Skip to content

Commit

Permalink
Merge pull request #91 from codefuse-ai/lhk_dev
Browse files Browse the repository at this point in the history
[fix] fix #90 self not constraint bug
  • Loading branch information
xiexie authored Jan 7, 2025
2 parents 7469990 + 354f07d commit 8fe1a45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion godel-script/godel-frontend/src/ir/name_mangling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ std::string rule_mangle(const std::string& name) {
prefix = "GT_";
} else if (starts_with(name, "typecheck_")) {
// typecheck_xxx -> TC_xxx
temp = name.substr(11);
temp = name.substr(10);
prefix = "TC_";
} else {
// std::cerr << "unknown rule name: " << name << std::endl;
Expand Down
10 changes: 9 additions & 1 deletion godel-script/godel-frontend/src/sema/ungrounded_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,18 @@ bool ungrounded_parameter_checker::is_schema_get_primary_key(call_root* node) {
if (node->get_call_head()->get_first_expression()->get_ast_class()!=ast_class::ac_identifier) {
return false;
}

const auto& head_type = node->get_call_head()->get_resolve();
// head type should not be global symbol or data-set type
if (head_type.is_global || head_type.type.is_set) {
return false;
}
if (node->get_call_chain().size()!=1) {

// schema get primary key pattern may be:
// 1. schema.primary_key
// 2. schema.primary_key.other_calls()
// so size should be >= 1
if (node->get_call_chain().size()<1) {
return false;
}
const auto name = head_type.type.full_path_name_without_set();
Expand All @@ -602,6 +609,7 @@ bool ungrounded_parameter_checker::is_schema_get_primary_key(call_root* node) {
return false;
}
const auto key = node->get_call_chain()[0]->get_field_name()->get_name();
// check if the field is primary key
return sc.fields.count(key) && sc.fields.at(key).primary;
}

Expand Down

0 comments on commit 8fe1a45

Please sign in to comment.