MCPcopy Create free account
hub / github.com/Restream/reindexer / Token2kv

Function Token2kv

cpp_src/core/query/sql/sqlparser.cc:352–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350};
351
352Variant Token2kv(const Token& tok, Tokenizer& parser, CompositeAllowed allowComposite, FieldAllowed allowField, NullAllowed allowNull) {
353 if (tok.Text() == "{"sv) {
354 // Composite value parsing
355 if (!allowComposite) {
356 const auto range = parser.Where(tok);
357 throw SqlParserError(range, "Unexpected '{{' in query, {}", range);
358 }
359 VariantArray compositeValues;
360 for (;;) {
361 auto nextTok = parser.NextToken();
362 compositeValues.push_back(Token2kv(nextTok, parser, CompositeAllowed_False, FieldAllowed_False, allowNull));
363 nextTok = parser.NextToken();
364 if (nextTok.Text() == "}"sv) {
365 return Variant(compositeValues); // end process
366 }
367 if (nextTok.Text() != ","sv) {
368 const auto range = parser.Where(nextTok);
369 throw SqlParserError(range, "Expected ',', but found '{}' in query, {}", nextTok.Text(), range);
370 }
371 }
372 }
373
374 const std::string_view value = tok.Text();
375 if (tok.Type() == TokenName) {
376 if (iequals(value, "true"sv)) {
377 return Variant{true};
378 }
379 if (iequals(value, "false"sv)) {
380 return Variant{false};
381 }
382 if (iequals(value, "null"sv)) {
383 if (allowNull) {
384 return Variant{};
385 }
386 } else if (allowField) {
387 return Variant{};
388 }
389 }
390
391 if (tok.Type() != TokenNumber && tok.Type() != TokenString) {
392 const auto range = parser.Where(tok);
393 throw SqlParserError(range, "Expected parameter, but found '{}' in query, {}", tok.Text(), range);
394 }
395
396 return GetVariantFromToken(tok);
397}
398
399template <typename Sortable>
400void SQLParser::parseOrderBy(Tokenizer& parser, Sortable& sortable) {

Callers 8

captureArrayContentMethod · 0.85
getPrimaryTokenMethod · 0.85
parseOrderByMethod · 0.85
addUpdateValueFunction · 0.85
parseCommandMethod · 0.85
parseValuesMethod · 0.85
parseWhereConditionMethod · 0.85
parseDWithinMethod · 0.85

Calls 8

SqlParserErrorClass · 0.85
iequalsFunction · 0.85
GetVariantFromTokenFunction · 0.85
TypeMethod · 0.65
VariantClass · 0.50
WhereMethod · 0.45
NextTokenMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected