Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用join关联查询数据时候发现关联表没有自动过滤掉软删除的数据 #6998

Open
shangyin2024 opened this issue Apr 27, 2024 · 0 comments
Assignees
Labels
type:with reproduction steps with reproduction steps

Comments

@shangyin2024
Copy link

GORM Playground Link

go-gorm/playground#724

Description

代码:

	err := DB.Debug().Model(artistModel).
		Select([]string{"artists.name"}).
		Joins("left join song_artists on artists.id = song_artists.artist_id").
		Where("song_artists.song_id = ?", songID).
		Scan(artistsNameArr).Error
  • 期望输出
SELECT artists.name FROM `artists` left join song_artists on artists.id = song_artists.artist_id WHERE song_artists.song_id = "003dc512121c4dfb898184565b92e8e8" AND `artists`.`deleted_at` IS NULL AND song_artists.`deleted_at` IS NULL 
  • 实际输出
SELECT artists.name FROM `artists` left join song_artists on artists.id = song_artists.artist_id WHERE song_artists.song_id = "003dc512121c4dfb898184565b92e8e8" AND `artists`.`deleted_at` IS NULL
@github-actions github-actions bot added the type:with reproduction steps with reproduction steps label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:with reproduction steps with reproduction steps
Projects
None yet
Development

No branches or pull requests

2 participants