Open
Conversation
a8m
reviewed
Aug 17, 2023
| FilterOps map[string]bool | ||
| } | ||
| type Field struct { | ||
| *FieldMeta |
Owner
There was a problem hiding this comment.
Why not inline its fields inside the Field type?
Comment on lines
+220
to
+226
| func (p *Parser) GetFields() []*Field { | ||
| fields := make([]*Field, 0, len(p.fields)) | ||
| for _, v := range p.fields { | ||
| fields = append(fields, v) | ||
| } | ||
| return fields | ||
| } |
Owner
There was a problem hiding this comment.
Suggested change
| func (p *Parser) GetFields() []*Field { | |
| fields := make([]*Field, 0, len(p.fields)) | |
| for _, v := range p.fields { | |
| fields = append(fields, v) | |
| } | |
| return fields | |
| } | |
| func (p *Parser) Fields() []*Field { | |
| fields := make([]*Field, 0, len(p.fields)) | |
| for _, v := range p.fields { | |
| fields = append(fields, v) | |
| } | |
| return fields | |
| } |
Why this method is needed? If it's for testing, let's use the existing public API instead.
| } | ||
|
|
||
| // Does not use config.Model, gets config from Fields) | ||
| func NewParserF(c Config, fields []*Field) (*Parser, error) { |
Owner
There was a problem hiding this comment.
Rename to: NewFieldsParser or add a new option as Config.Fields.
Also, an error should return if c.Model was set as the two are mutually exclusive.
Owner
|
Thanks for the contribution, @ashtonian. It's appreciated. |
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.
This adds functions to expose the internal fields object and to create a new parser from a slice of field objects. This lets the user dynamically configure a parser, my use case is to change rql config based on permissions. I would also like to expose the parsed data and related field information to be able to document related metadata for the user like what are available operations. I think it pairs well with #51.
I think it would be nice to refactor to the following, but this is breaking:
Added: