File tree Expand file tree Collapse file tree 2 files changed +30
-5
lines changed
Expand file tree Collapse file tree 2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -61,11 +61,10 @@ func TestParse(t *testing.T) {
6161 want : nil ,
6262 wantErr : false ,
6363 }, {
64- name : "co-related subquery 1" ,
65- args : args {s : `SELECT (SELECT Id FROM con.Departments where contact=contact.id) qwerty FROM Contact con` },
66- want : nil ,
67- wantErr : false ,
68- dbgBreak : true ,
64+ name : "co-related subquery 1" ,
65+ args : args {s : `SELECT (SELECT Id FROM con.Departments where contact=contact.id) qwerty FROM Contact con` },
66+ want : nil ,
67+ wantErr : false ,
6968 }, {
7069 name : "co-related subquery 2" ,
7170 args : args {s : `SELECT (SELECT Id FROM con.Departments where contact=con.id) qwerty FROM Contact con` },
@@ -76,6 +75,17 @@ func TestParse(t *testing.T) {
7675 args : args {s : `SELECT (SELECT Id, con.Id FROM con.Departments) qwerty FROM Contact con` },
7776 want : nil ,
7877 wantErr : true ,
78+ }, {
79+ name : "fieldset 1" ,
80+ args : args {s : `SELECT fields(acc.all) FROM Contact con, con.Account acc` },
81+ want : nil ,
82+ wantErr : false ,
83+ }, {
84+ name : "fieldset 2" ,
85+ args : args {s : `SELECT fields(con.acc.all) FROM Contact con, con.Account acc` },
86+ want : nil ,
87+ wantErr : true ,
88+ dbgBreak : true ,
7989 }}
8090 for _ , tt := range tests {
8191 t .Run (tt .name , func (t * testing.T ) {
Original file line number Diff line number Diff line change @@ -209,6 +209,21 @@ func (ctx *normalizeQueryContext) normalizeFieldName(
209209
210210 qualifyName ()
211211
212+ key := nameutil .MakeDottedKeyIgnoreCase (field .Name , len (field .Name )- 1 )
213+ fullyQualifiedName , ok := objNameMap [key ]
214+
215+ if ! ok {
216+ return errors .New (
217+ "Field set 'Fields()' parameter refers unknown object: " +
218+ strings .Join (field .Name , "." ))
219+ }
220+
221+ fqnLen := len (fullyQualifiedName )
222+ s := make ([]string , 0 , fqnLen + 1 )
223+ s = append (s , fullyQualifiedName ... )
224+ s = append (s , field .Name [len (field .Name )- 1 ])
225+ field .Name = s
226+
212227 case "count" :
213228 switch len (field .Parameters ) {
214229 case 0 :
You can’t perform that action at this time.
0 commit comments