Skip to content

Commit

Permalink
Remove test that would enforce a way of scanning values into an *int
Browse files Browse the repository at this point in the history
The reason for removing this test is that PGx4 and PGx5 don't agree
on how to work with *int, thus, if I made the behavior of KSQL
match pgx5 the test for pgx4 would break and vice-versa.

Fyi KSQL was made to do the same as pgx4 for now, I will create
an issue on pgx to ask why pgx5 is doing it differently, maybe
if he has a good reason for this I should do the same.
  • Loading branch information
VinGarcia committed Nov 4, 2024
1 parent 3f0e9b9 commit d84d079
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 33 deletions.
2 changes: 1 addition & 1 deletion adapters/kpgx5/kpgx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestAdapter(t *testing.T) {
postgresURL, closePostgres := startPostgresDB(ctx, "ksql")
defer closePostgres()

ksql.RunTestsForAdapter(t, "kpgx", sqldialect.PostgresDialect{}, postgresURL, func(t *testing.T) (ksql.DBAdapter, io.Closer) {
ksql.RunTestsForAdapter(t, "kpgx5", sqldialect.PostgresDialect{}, postgresURL, func(t *testing.T) (ksql.DBAdapter, io.Closer) {
pool, err := pgxpool.New(ctx, postgresURL)
if err != nil {
t.Fatal(err.Error())
Expand Down
32 changes: 0 additions & 32 deletions test_adapters.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,38 +869,6 @@ func InsertTest(
tt.AssertEqual(t, result.Address, u.Address)
})

t.Run("should insert one user correctly when the ID is a pointer to int reusing existing int", func(t *testing.T) {
c := newTestDB(db, dialect)

type ptrUser struct {
ID *uint `ksql:"id"`
Name string `ksql:"name"`
Address address `ksql:"address,json"`
Age int `ksql:"age"`
}
var id uint = 0
u := ptrUser{
ID: &id,
Name: "Paulo",
Address: address{
Country: "Brazil",
},
}

err := c.Insert(ctx, usersTable, &u)
tt.AssertNoErr(t, err)
tt.AssertNotEqual(t, u.ID, nil)
tt.AssertEqual(t, id, *u.ID)

result := user{}
err = getUserByID(db, dialect, &result, *u.ID)
tt.AssertNoErr(t, err)

tt.AssertEqual(t, result.ID, id)
tt.AssertEqual(t, result.Name, u.Name)
tt.AssertEqual(t, result.Address, u.Address)
})

t.Run("should insert ignoring the ID with multiple ids", func(t *testing.T) {
if dialect.InsertMethod() != sqldialect.InsertWithLastInsertID {
return
Expand Down

0 comments on commit d84d079

Please sign in to comment.