@@ -11,11 +11,16 @@ type SelectItem struct {
1111}
1212
1313func ParseSelectString (ctx context.Context , sel string ) (* GoDataSelectQuery , error ) {
14+ return GlobalExpressionParser .ParseSelectString (ctx , sel )
15+ }
16+
17+ func (p * ExpressionParser ) ParseSelectString (ctx context.Context , sel string ) (* GoDataSelectQuery , error ) {
1418 items := strings .Split (sel , "," )
1519
1620 result := []* SelectItem {}
1721
1822 for _ , item := range items {
23+ item = strings .TrimSpace (item )
1924
2025 cfg , hasComplianceConfig := ctx .Value (odataCompliance ).(OdataComplianceConfig )
2126 if ! hasComplianceConfig {
@@ -27,11 +32,28 @@ func ParseSelectString(ctx context.Context, sel string) (*GoDataSelectQuery, err
2732 return nil , BadRequestError ("Extra comma in $select." )
2833 }
2934
30- segments := []* Token {}
31- for _ , val := range strings .Split (item , "/" ) {
32- segments = append (segments , & Token {Value : val })
35+ if _ , err := p .tokenizer .Tokenize (ctx , item ); err != nil {
36+ switch e := err .(type ) {
37+ case * GoDataError :
38+ return nil , & GoDataError {
39+ ResponseCode : e .ResponseCode ,
40+ Message : "Invalid $select value" ,
41+ Cause : e ,
42+ }
43+ default :
44+ return nil , & GoDataError {
45+ ResponseCode : 500 ,
46+ Message : "Invalid $select value" ,
47+ Cause : e ,
48+ }
49+ }
50+ } else {
51+ segments := []* Token {}
52+ for _ , val := range strings .Split (item , "/" ) {
53+ segments = append (segments , & Token {Value : val })
54+ }
55+ result = append (result , & SelectItem {segments })
3356 }
34- result = append (result , & SelectItem {segments })
3557 }
3658
3759 return & GoDataSelectQuery {result , sel }, nil
0 commit comments