Skip to content

Commit 354f07d

Browse files
committed
fix #90 issue
1 parent bcf790f commit 354f07d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

godel-script/godel-frontend/src/sema/ungrounded_checker.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,18 @@ bool ungrounded_parameter_checker::is_schema_get_primary_key(call_root* node) {
581581
if (node->get_call_head()->get_first_expression()->get_ast_class()!=ast_class::ac_identifier) {
582582
return false;
583583
}
584+
584585
const auto& head_type = node->get_call_head()->get_resolve();
586+
// head type should not be global symbol or data-set type
585587
if (head_type.is_global || head_type.type.is_set) {
586588
return false;
587589
}
588-
if (node->get_call_chain().size()!=1) {
590+
591+
// schema get primary key pattern may be:
592+
// 1. schema.primary_key
593+
// 2. schema.primary_key.other_calls()
594+
// so size should be >= 1
595+
if (node->get_call_chain().size()<1) {
589596
return false;
590597
}
591598
const auto name = head_type.type.full_path_name_without_set();
@@ -602,6 +609,7 @@ bool ungrounded_parameter_checker::is_schema_get_primary_key(call_root* node) {
602609
return false;
603610
}
604611
const auto key = node->get_call_chain()[0]->get_field_name()->get_name();
612+
// check if the field is primary key
605613
return sc.fields.count(key) && sc.fields.at(key).primary;
606614
}
607615

0 commit comments

Comments
 (0)