Repository navigation
Let metadata <expr> and stor insert/update record flags ignore pipeline input instead of erroring - #19254
Merged
Conversation
…peline input instead of erroring
Closed
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
metadatawith an argument fails when the call also has pipeline input:The user never piped anything into
metadatahere. The first statement of a block receives the block's input, which is intended ("a" | do { let x = (str uppercase); $x }returnsA), sometadatagets the closure's input along with$xand refuses. The same check rejects"a" | metadata $in, because$instores the input in the variable and still passes it to the call.The check came in with another PR. A command can't tell implicit block input from an explicit pipe at run time: both arrive as ordinary
PipelineDatain the same register.This PR removes the check. When
metadatagets an argument, the result describes only that argument: a record with itsspan. The input and its pipeline metadata are ignored. Before #16049 the argument's span was merged with the input's pipeline metadata, which attached the input's metadata to an unrelated value:stor insert --data-recordandstor update --update-recordhad the same input-versus-argument check and failed the same way inside a block:[{a: 1}] | each {|r| stor insert -t t -d $r } # Error: Pipeline and Flag both being usedUser-facing changes (Release notes)
metadata <expr>andstor insert/updaterecord flags now ignore pipeline input instead of erroringmetadata <expression>now returns only the argument's span and ignores pipeline input instead of erroring. This allows calls such as[1] | each {|x| let s = (metadata $x).span; $s }and"a" | metadata $into work even when they receive implicit block input or explicit pipeline input. Without an argument,metadatastill reports the input's pipeline metadata.stor insert --data-recordandstor update --update-recordlikewise use the flag's record and ignore pipeline input instead of failing with "Pipeline and Flag both being used", allowing these calls to work inside blocks.Additional notes
ls | metadata $x,ls | stor insert -t t -d {a: 1}). Erroring only on an explicit pipe would need the compiler to mark implicit block input, which no command can see today.metadata $inreturns only the span. The input'spath_columns,content_typeand custom keys are not included; usemetadatawithout an argument for those. (sourcefromopenis already removed when the input is collected into$in.)