MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / getFieldName

Method getFieldName

crates/bindings-cpp/src/internal/v9_builder.cpp:193–209  ·  view source on GitHub ↗

Helper function to get field name from Product type structure

Source from the content-addressed store, hash-verified

191
192// Helper function to get field name from Product type structure
193std::string V9Builder::getFieldName(const bsatn::AlgebraicType& table_type, uint16_t column_index) const {
194 if (table_type.tag() != bsatn::AlgebraicTypeTag::Product) {
195 return "column" + std::to_string(column_index);
196 }
197
198 const auto& product = table_type.as_product();
199 if (column_index >= product.elements.size()) {
200 return "column" + std::to_string(column_index);
201 }
202
203 const auto& element = product.elements[column_index];
204 if (element.name.has_value()) {
205 return element.name.value();
206 }
207
208 return "column" + std::to_string(column_index);
209}
210
211// Helper function to generate constraints for primary key
212std::vector<RawConstraintDefV9> V9Builder::generateConstraintsForPrimaryKey(

Callers

nothing calls this directly

Calls 4

to_stringFunction · 0.50
tagMethod · 0.45
sizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected