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

検証レシート