Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SQL printed to terminal is error  #6898

@wangzeping722

Description

@wangzeping722

GORM Playground Link

go-gorm/playground#702

Description

When I use the where statement, the printed sql in console is wrong that makes me think there is something wrong with the sql statement.

It should print number rather than string when the underlying type is int.

type UserStatus int

const (
	Normal UserStatus = 1
	Forbid UserStatus = 2
)
// print: SELECT * FROM `users` WHERE status = '1' AND `users`.`deleted_at` IS NULL
DB.Where("status = ?", Normal).Find(&users)

// print: SELECT * FROM `users` WHERE status = 1 AND `users`.`deleted_at` IS NULL
DB.Where("status = ?", 1).Find(&users)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions