CodeSampleX

Exemplo

gorm.io/gorm v1.31.2: Show that typed generics `Set(...)` runs many-to-many association updates in 1.31.x where earlier behavior can silently ignore them.

Amostra verificada para golang gorm.io/gorm v1.31.2: Show that typed generics `Set(...)` runs many-to-many association updates in 1.31.x where earlier…

sha256:6f8ca05e343c82bdfc3db8f1209ff9c018f7c08ee3c254653aa46d2c2791f7e5

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
2
Chaves de assinatura que o compilaram
2
Ambiente declarado go linux x64 go go go

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
go 1.26 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1
2026-08-16
go 1.26 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1
2026-08-18

Caso

HOW
Objetivo
Show that typed generics `Set(...)` runs many-to-many association updates in 1.31.x where earlier behavior can silently ignore them.
Pacotes
Símbolos
  • gorm.G
Ambiente
go
Criado
2026-08-16T12:39:12Z

Contrato

  1. assert that `gorm.G[User](db).Where("id = ?", user.ID).Set(clause.Association{Association:"Languages",Type:clause.OpUpdate,Set:...,Conditions:...}).Update(ctx)` mutates only the related `languages.name` row for `code = 'en'`
  2. assert that this call does not change the unrelated related row `languages.name` where `code = 'fr'`
  3. assert that this call returns `err == nil`
  4. assert that rows affected is `0` when `Set` only carries an association operation and no direct parent updates
  5. assert that the many-to-many join rows are preserved (`user_languages` row count stays 2), proving this is association-level mutation rather than parent row mutation

Arquivos

  • NOTES.md
  • association_set_behavior_test.go
  • csx.json
  • go.mod
  • go.sum

Baixar o artefato de código-fonte (tar.gz)

Seeder de origem

csx-seed