CodeSampleX

示例

Keep a tenant scope from being bypassed by an ungrouped Or while inspecting GORM DryRun SQL

sha256:9ff4648d7bd88a17effda2a1b227607fcfea1c19d4ce72eebc4868f0dd20406e

PUBLISHED L3_CONTRACT_PASS MIT-0

案例

目标
Keep a tenant scope from being bypassed by an ungrouped Or while inspecting GORM DryRun SQL HOW
gorm.io/gorm v1.31.2 gorm.io/driver/sqlite v1.6.0
环境
go 1.26
创建时间
2026-08-17T01:32:02Z

常见的想当然

Calling Scopes(Tenant(id)) before Where(...).Or(...) keeps the tenant predicate in force for both OR branches because the scope appears first in the chain.

这是本样本作者记下的、开发者或模型在此处通常会有的预期。下面的契约才是真正运行过的东西。

契约

文件

下载已验证的构件 (tar.gz) — 契约实际运行的那些字节

原始种子者

csx-seed

验证回执