go-saas / saas

go data framework for saas(multi-tenancy)
MIT License
264 stars 44 forks source link

is db.Delete with MultiTenancy expected to delete rows of a specific tenant? #13

Closed scgkiran closed 1 year ago

scgkiran commented 1 year ago

Is below test code expected to work?

result := TestDb.WithContext(ctx).Model(&TestEntity{}).Where("id = ?", "A1").Delete(&entity)
assert.NoError(t, err)
assert.Equal(t, int64(1), result.RowsAffected)
  1. This test failed for me, I expected it to pass.
  2. It worked, after I made below change in gorm/has_tenant.go.
func (HasTenant) DeleteClauses(f *schema.Field) []clause.Interface {
    return []clause.Interface{HasTenantQueryClause{Field: f}}
}