Skip to content

Commit

Permalink
refactor: unify code style, use existing patterns, and highlight impl…
Browse files Browse the repository at this point in the history
…emented interfaces in structs
  • Loading branch information
bevzzz committed Dec 6, 2022
1 parent 8abcf63 commit 533383a
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 84 deletions.
16 changes: 10 additions & 6 deletions internal/dbtest/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,8 @@ func TestAlterTable(t *testing.T) {
{
"rename column", needsAlterTable,
func(db *bun.DB) schema.QueryAppender {
return db.NewAlterTable().Model((*Model)(nil)).RenameColumn("old", "new")
return db.NewAlterTable().Model((*Model)(nil)).
RenameColumn().Column("old").To("new")
},
},
{
Expand All @@ -970,29 +971,32 @@ func TestAlterTable(t *testing.T) {
{
"rename table", needsAlterTable,
func(db *bun.DB) schema.QueryAppender {
return db.NewAlterTable().Model((*Model)(nil)).Rename("new_models")
return db.NewAlterTable().Model((*Model)(nil)).
Rename().To("new_models")
},
},
{
"rename table if exists", needsAlterTable,
func(db *bun.DB) schema.QueryAppender {
return db.NewAlterTable().Model((*Model)(nil)).IfExists().Rename("new_models")
return db.NewAlterTable().Model((*Model)(nil)).IfExists().
Rename().To("new_models")
},
},
{
"change column type", needsAlterTable,
func(db *bun.DB) schema.QueryAppender {
// Change column type with common SQL data type
return db.NewAlterTable().Model((*Model)(nil)).AlterColumn("old").Type(sqltype.Blob)
return db.NewAlterTable().Model((*Model)(nil)).
AlterColumn().Column("old").Type(sqltype.Blob)
},
},
{
"change column type chained", needsAlterTable,
func(db *bun.DB) schema.QueryAppender {
// Alter 2 columns in a chained query
return db.NewAlterTable().Model((*Model)(nil)).
AlterColumn("old").Type(sqltype.Blob).
AlterColumn("active").Type(sqltype.SmallInt)
AlterColumn().Column("old").Type(sqltype.Blob).
AlterColumn().Column("active").Type(sqltype.SmallInt)
},
},
{
Expand Down

0 comments on commit 533383a

Please sign in to comment.