fix(repository): correct query syntax to get correctly built-in models
This commit is contained in:
@@ -28,7 +28,7 @@ func (r *modelRepository) Create(ctx context.Context, m *types.Model) error {
|
|||||||
func (r *modelRepository) GetByID(ctx context.Context, tenantID uint64, id string) (*types.Model, error) {
|
func (r *modelRepository) GetByID(ctx context.Context, tenantID uint64, id string) (*types.Model, error) {
|
||||||
var m types.Model
|
var m types.Model
|
||||||
if err := r.db.WithContext(ctx).Where("id = ?", id).Where(
|
if err := r.db.WithContext(ctx).Where("id = ?", id).Where(
|
||||||
"tenant_id = ? OR is_builtin = true", tenantID,
|
"(tenant_id = ? OR is_builtin = true)", tenantID,
|
||||||
).First(&m).Error; err != nil {
|
).First(&m).Error; err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@@ -44,7 +44,7 @@ func (r *modelRepository) List(
|
|||||||
) ([]*types.Model, error) {
|
) ([]*types.Model, error) {
|
||||||
var models []*types.Model
|
var models []*types.Model
|
||||||
query := r.db.WithContext(ctx).Where(
|
query := r.db.WithContext(ctx).Where(
|
||||||
"tenant_id = ? OR is_builtin = true", tenantID,
|
"(tenant_id = ? OR is_builtin = true)", tenantID,
|
||||||
)
|
)
|
||||||
|
|
||||||
if modelType != "" {
|
if modelType != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user