Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading