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

When I do Find(&obj) in contex cancelled state, it falls into panic state v1.25.11 #7119

Closed
ozkansen opened this issue Jul 19, 2024 · 2 comments
Assignees
Labels

Comments

@ozkansen
Copy link

When I do Find(&obj) in contex cancelled state, it falls into panic state. This situation started to occur with v1.25.11.

Example code:

func (p PlaylistRepository) GetPlaylistItemsByPlaylistID(ctx context.Context, id uint, limit, offset int) (result *models.PlaylistItemWithMediaList, err error) {
	var (
		dbPlaylistItems []dbmodels.PlaylistItemWithMedia
		count           int64
	)
	if err = p.db.WithContext(ctx).
		Select(
			"pi.created_at as item_created_at",
			"pi.detail as item_detail",
			"pi.id as item_id",
			"pi.\"order\" as item_order",
			"pi.playlist_id as item_playlist_id",
			"pi.fixed as item_fixed",
			"m.id as media_id",
			"m.uuid as media_uuid",
			"m.ext as media_ext",
			"m.url as media_url",
			"m.thumbnail as media_thumbnail",
			"m.title as media_title",
			"m.type as media_type",
			"m.storage_type as media_storage_type",
			"m.size as media_size",
			"m.customer_id as media_customer_id",
			"m.user_id as user_id",
			"m.info as media_info",
			"m.checksum as media_checksum",
			"u.full_name as user_full_name",
			"u.job_title as user_job_title",
			"u.email as user_email",
			"u.mobile_number as user_mobile_number",
			"u.department as user_department",
		).
		Table("playlist_items pi").
		Joins(
			"left join media m on m.id = pi.media_id " 
				"left join users u on m.user_id = u.id",
		).
		Where("pi.playlist_id = ?", id).
		Count(&count).Limit(limit).Offset(offset).
		Find(&dbPlaylistItems).Error; err != nil {
		err = fmt.Errorf("get playlist items by playlist id / find : %w", err)
		return
	}

	playlistItems := make([]*models.PlaylistItemWithMedia, 0, len(dbPlaylistItems))

	for i := range dbPlaylistItems {
		var pm *models.PlaylistItemWithMedia

		if pm, err = dbPlaylistItems[i].To(); err != nil {
			err = fmt.Errorf("get playlist items by playlist id / convert to : %w", err)
			return
		}

		playlistItems = append(playlistItems, pm)
	}

	result = &models.PlaylistItemWithMediaList{
		Items:  playlistItems,
		Count:  count,
		Limit:  limit,
		Offset: offset,
	}
	return
}
@github-actions github-actions bot added the type:missing reproduction steps missing reproduction steps label Jul 19, 2024
Copy link

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

@ozkansen ozkansen changed the title When I do Find(&obj) in contex cancelled state, it falls into panic state When I do Find(&obj) in contex cancelled state, it falls into panic state v1.25.11 Jul 22, 2024
Copy link

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants