Skip to content

Commit f4b37e0

Browse files
authored
Remove unused ListAll() from objecttype repository (#297)
1 parent e6f0e19 commit f4b37e0

File tree

5 files changed

+1
-86
lines changed

5 files changed

+1
-86
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ apirunner.conf
33
.DS_Store
44
bin/
55
dist/
6+
.idea/

pkg/authz/objecttype/mysql.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -112,34 +112,6 @@ func (repo MySQLRepository) GetByTypeId(ctx context.Context, typeId string) (Mod
112112
return &objectType, nil
113113
}
114114

115-
func (repo MySQLRepository) ListAll(ctx context.Context) ([]Model, error) {
116-
models := make([]Model, 0)
117-
objectTypes := make([]ObjectType, 0)
118-
err := repo.DB.SelectContext(
119-
ctx,
120-
&objectTypes,
121-
`
122-
SELECT id, typeId, definition, createdAt, updatedAt, deletedAt
123-
FROM objectType
124-
WHERE
125-
deletedAt IS NULL
126-
`,
127-
)
128-
129-
if err != nil {
130-
if errors.Is(err, sql.ErrNoRows) {
131-
return models, nil
132-
}
133-
return models, errors.Wrap(err, "error listing all object types")
134-
}
135-
136-
for i := range objectTypes {
137-
models = append(models, &objectTypes[i])
138-
}
139-
140-
return models, nil
141-
}
142-
143115
func (repo MySQLRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error) {
144116
models := make([]Model, 0)
145117
objectTypes := make([]ObjectType, 0)

pkg/authz/objecttype/postgres.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -118,35 +118,6 @@ func (repo PostgresRepository) GetByTypeId(ctx context.Context, typeId string) (
118118
return &objectType, nil
119119
}
120120

121-
func (repo PostgresRepository) ListAll(ctx context.Context) ([]Model, error) {
122-
models := make([]Model, 0)
123-
objectTypes := make([]ObjectType, 0)
124-
err := repo.DB.SelectContext(
125-
ctx,
126-
&objectTypes,
127-
`
128-
SELECT id, type_id, definition, created_at, updated_at, deleted_at
129-
FROM object_type
130-
WHERE
131-
deleted_at IS NULL
132-
`,
133-
)
134-
135-
if err != nil {
136-
if errors.Is(err, sql.ErrNoRows) {
137-
return models, nil
138-
}
139-
140-
return models, errors.Wrap(err, "error listing all object types")
141-
}
142-
143-
for i := range objectTypes {
144-
models = append(models, &objectTypes[i])
145-
}
146-
147-
return models, nil
148-
}
149-
150121
func (repo PostgresRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error) {
151122
models := make([]Model, 0)
152123
objectTypes := make([]ObjectType, 0)

pkg/authz/objecttype/repository.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ type ObjectTypeRepository interface {
2727
Create(ctx context.Context, objectType Model) (int64, error)
2828
GetById(ctx context.Context, id int64) (Model, error)
2929
GetByTypeId(ctx context.Context, typeId string) (Model, error)
30-
ListAll(ctx context.Context) ([]Model, error)
3130
List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error)
3231
UpdateByTypeId(ctx context.Context, typeId string, objectType Model) error
3332
DeleteByTypeId(ctx context.Context, typeId string) error

pkg/authz/objecttype/sqlite.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -118,34 +118,6 @@ func (repo SQLiteRepository) GetByTypeId(ctx context.Context, typeId string) (Mo
118118
return &objectType, nil
119119
}
120120

121-
func (repo SQLiteRepository) ListAll(ctx context.Context) ([]Model, error) {
122-
models := make([]Model, 0)
123-
objectTypes := make([]ObjectType, 0)
124-
err := repo.DB.SelectContext(
125-
ctx,
126-
&objectTypes,
127-
`
128-
SELECT id, typeId, definition, createdAt, updatedAt, deletedAt
129-
FROM objectType
130-
WHERE
131-
deletedAt IS NULL
132-
`,
133-
)
134-
135-
if err != nil {
136-
if errors.Is(err, sql.ErrNoRows) {
137-
return models, nil
138-
}
139-
return models, errors.Wrap(err, "error listing all object types")
140-
}
141-
142-
for i := range objectTypes {
143-
models = append(models, &objectTypes[i])
144-
}
145-
146-
return models, nil
147-
}
148-
149121
func (repo SQLiteRepository) List(ctx context.Context, listParams service.ListParams) ([]Model, *service.Cursor, *service.Cursor, error) {
150122
models := make([]Model, 0)
151123
objectTypes := make([]ObjectType, 0)

0 commit comments

Comments
 (0)