Skip to content

Commit e083244

Browse files
authored
Allow empty tables to be used in rulesets (#1404)
* Allow empty tables to be used in rulesets * Move the test to different ddl to avoid polluting ddl used for other examples
1 parent 8cb6c3c commit e083244

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

production/schemas/test/prerequisites/prerequisites.ddl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,12 @@ table person (
8686
floor references floor
8787
where person.floor_num = floor.num
8888
)
89+
90+
table state (
91+
pick bool,
92+
place bool
93+
)
94+
95+
table pick_action ()
96+
97+
table move_action ()

production/tools/gaia_translate/src/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,10 @@ void generate_navigation(StringRef anchor_table, Rewriter& rewriter)
742742
replacement_string.append(",");
743743
}
744744
}
745-
replacement_string.resize(replacement_string.size() - 1);
745+
if (!function_arguments.empty())
746+
{
747+
replacement_string.resize(replacement_string.size() - 1);
748+
}
746749
replacement_string.append("))");
747750

748751
rewriter.ReplaceText(insert_data.expression_range, replacement_string);

production/tools/gaia_translate/tests/test_rulesets.ruleset

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,3 +824,23 @@ ruleset vlr_rules
824824
gaia_log::app().info("---");
825825
}
826826
}
827+
828+
ruleset pick_and_place_ruleset
829+
{
830+
{
831+
if (@pick && !@place)
832+
{
833+
pick_action.insert();
834+
}
835+
}
836+
837+
on_insert(pick_action)
838+
{
839+
move_action.insert();
840+
}
841+
842+
on_insert(move_action)
843+
{
844+
gaia_log::app().info("Moving...");
845+
}
846+
}

third_party/production/TranslationEngineLLVM/clang/lib/Catalog/GaiaCatalog.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void GaiaCatalog::fillTableData()
100100
continue;
101101
}
102102
CatalogTableData table_data;
103+
table_data.dbName = table.database().name();
103104
m_catalogTableData[table.name()] = table_data;
104105
}
105106

@@ -133,8 +134,8 @@ void GaiaCatalog::fillTableData()
133134
m_catalogTableData.clear();
134135
return;
135136
}
136-
CatalogTableData table_data = table_data_iterator->second;
137-
if (table_data.fieldData.find(field.name()) != table_data.fieldData.end())
137+
138+
if (table_data_iterator->second.fieldData.find(field.name()) != table_data_iterator->second.fieldData.end())
138139
{
139140
m_diags.Report(diag::err_duplicate_field) << field.name();
140141
m_catalogTableData.clear();
@@ -146,9 +147,7 @@ void GaiaCatalog::fillTableData()
146147
field_data.isDeprecated = field.deprecated();
147148
field_data.isArray = field.repeated_count() == 0;
148149
field_data.fieldType = static_cast<data_type_t>(field.type());
149-
table_data.dbName = table.database().name();
150-
table_data.fieldData[field.name()] = field_data;
151-
m_catalogTableData[table.name()] = table_data;
150+
table_data_iterator->second.fieldData[field.name()] = field_data;
152151
}
153152

154153
for (const auto& relationship : gaia_relationship_t::list())

0 commit comments

Comments
 (0)