Skip to content

Commit f71061f

Browse files
fankclaude
andauthored
fix: Object.Filter() method now properly includes attributes when requested (#388)
Resolves #387: The Object.Filter() method was returning empty results when attributes=true because it wasn't including the includeAttributes=true parameter in the API request URL. Changes: - Fixed logic in Filter() method to explicitly set includeAttributes parameter for both true and false cases - Added comprehensive test coverage for attributes=true scenario - Maintains backward compatibility with existing behavior 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 07511de commit f71061f

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

assets/internal/object_impl.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ func (i *internalObjectImpl) Filter(ctx context.Context, workspaceID, aql string
159159
params.Add("startAt", strconv.Itoa(startAt))
160160
params.Add("maxResults", strconv.Itoa(maxResults))
161161

162-
if !attributes {
162+
if attributes {
163+
params.Add("includeAttributes", "true")
164+
} else {
163165
params.Add("includeAttributes", "false")
164166
}
165167

assets/internal/object_impl_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,32 @@ func Test_internalObjectImpl_Filter(t *testing.T) {
11841184
wantErr: true,
11851185
Err: model.ErrNoAqlQuery,
11861186
},
1187+
{
1188+
name: "when the parameters are correct with attributes enabled",
1189+
args: args{
1190+
ctx: context.Background(),
1191+
workspaceID: "workspace-uuid-sample",
1192+
aql: "objectType = Office AND Name LIKE SYD",
1193+
attributes: true,
1194+
startAt: 50,
1195+
maxResults: 50,
1196+
},
1197+
on: func(fields *fields) {
1198+
client := mocks.NewConnector(t)
1199+
client.On("NewRequest",
1200+
context.Background(),
1201+
http.MethodPost,
1202+
"jsm/assets/workspace/workspace-uuid-sample/v1/object/aql?includeAttributes=true&maxResults=50&startAt=50",
1203+
"",
1204+
map[string]interface{}{"qlQuery": "objectType = Office AND Name LIKE SYD"}).
1205+
Return(&http.Request{}, nil)
1206+
client.On("Call",
1207+
&http.Request{},
1208+
&model.ObjectListResultScheme{}).
1209+
Return(&model.ResponseScheme{}, nil)
1210+
fields.c = client
1211+
},
1212+
},
11871213
}
11881214

11891215
for _, testCase := range testCases {

0 commit comments

Comments
 (0)