Merge pull request #33842 from suhr25/fix/notifications-limit-zero-ignored
fix: handle limit=0 in getNotifications query
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-notifications-backend': patch
|
||||
---
|
||||
|
||||
Fix handling of `limit=0` in `getNotifications` query to return empty results instead of all notifications
|
||||
@@ -469,6 +469,11 @@ describe.each(databases.eachSupportedId())(
|
||||
id3,
|
||||
]);
|
||||
});
|
||||
|
||||
it('should return empty array when limit is 0', async () => {
|
||||
const result = await storage.getNotifications({ user, limit: 0 });
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getNotifications sorting', () => {
|
||||
|
||||
@@ -289,11 +289,11 @@ export class DatabaseNotificationsStore implements NotificationsStore {
|
||||
}
|
||||
}
|
||||
|
||||
if (options.limit) {
|
||||
if (options.limit !== undefined) {
|
||||
query.limit(options.limit);
|
||||
}
|
||||
|
||||
if (options.offset) {
|
||||
if (options.offset !== undefined) {
|
||||
query.offset(options.offset);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user