Skip to content

Commit

Permalink
Add failing test for multiline Where with OR
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-wbcx committed Jan 22, 2025
1 parent 926be68 commit 21f2f78
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,38 @@ package main

import (
"testing"
"time"
)

// GORM_REPO: https://github.com/go-gorm/gorm.git
// GORM_BRANCH: master
// TEST_DRIVERS: sqlite, mysql, postgres, sqlserver

func TestGORM(t *testing.T) {
user := User{Name: "jinzhu"}

user := User{
Name: "jinzhu",
}
DB.Create(&user)

var result User
if err := DB.First(&result, user.ID).Error; err != nil {
bday := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC)
user2 := User{
Name: "sam-wbcx",
Birthday: &bday,
}
DB.Create(&user2)

var results []User
if err := DB.
Where(`
birthday IS NULL
OR birthday < CURRENT_TIMESTAMP
`).
Where("name = ?", user2.Name).
Find(&results).Error; err != nil {
t.Errorf("Failed, got error: %v", err)
}

if len(results) != 1 {
t.Errorf("Failed, returned %d results", len(results))
}
}

0 comments on commit 21f2f78

Please sign in to comment.