Skip to content

Error in generation groups queries in scopes #6148

@daashuun

Description

@daashuun

GORM Playground Link

https://github.com/daashuun/playground

Description

I tried to make
SELECT * FROM "test" WHERE a = 1 AND (b = 2 OR c = 3)

but this request

DB.Table("test").Scopes(
  func(d *gorm.DB) *gorm.DB {
	  return d.Where("a = 1")
  },
  func(d *gorm.DB) *gorm.DB {
	  return d.Where(d.Or("b = 2").Or("c = 3"))
  },
).Rows()

makes sql
SELECT * FROM "test" WHERE a = 1 OR b = 2 OR c = 3 AND (a = 1 OR b = 2 OR c = 3)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions