Skip to content

Commit

Permalink
refactor: clean up exported funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
aldy505 committed Jul 31, 2021
1 parent ecefcdb commit 49cf645
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
12 changes: 6 additions & 6 deletions bob.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ type BobBuilder interface {

// CreateTable creates a table with CreateBuilder interface
func (b BobBuilderType) CreateTable(table string) CreateBuilder {
return CreateBuilder(b).Name(table)
return CreateBuilder(b).name(table)
}

// CreateTableIfNotExists creates a table with CreateBuilder interface, if the table doesn't exists.
func (b BobBuilderType) CreateTableIfNotExists(table string) CreateBuilder {
return CreateBuilder(b).Name(table).IfNotExists()
return CreateBuilder(b).name(table).ifNotExists()
}

// HasTable checks if a table exists with HasBuilder interface
Expand All @@ -50,22 +50,22 @@ func (b BobBuilderType) HasColumn(column string) HasBuilder {

// DropTable drops (delete contents & remove) a table from the database.
func (b BobBuilderType) DropTable(table string) DropBuilder {
return DropBuilder(b).DropTable(table)
return DropBuilder(b).dropTable(table)
}

// DropTable drops (delete contents & remove) a table from the database if the table exists.
func (b BobBuilderType) DropTableIfExists(table string) DropBuilder {
return DropBuilder(b).DropTable(table).IfExists()
return DropBuilder(b).dropTable(table).ifExists()
}

// RenameTable simply renames an exisisting table.
func (b BobBuilderType) RenameTable(from, to string) RenameBuilder {
return RenameBuilder(b).From(from).To(to)
return RenameBuilder(b).from(from).to(to)
}

// Truncate performs TRUNCATE function. It deletes all contents from a table but not deleting the table.
func (b BobBuilderType) Truncate(table string) TruncateBuilder {
return TruncateBuilder(b).Truncate(table)
return TruncateBuilder(b).truncate(table)
}

func (b BobBuilderType) Upsert(table string, dialect int) UpsertBuilder {
Expand Down
8 changes: 4 additions & 4 deletions create.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ func init() {
builder.Register(CreateBuilder{}, createData{})
}

// Name sets the table name
func (b CreateBuilder) Name(name string) CreateBuilder {
// name sets the table name
func (b CreateBuilder) name(name string) CreateBuilder {
return builder.Set(b, "TableName", name).(CreateBuilder)
}

// IfNotExists adds IF NOT EXISTS to the query
func (b CreateBuilder) IfNotExists() CreateBuilder {
// ifNotExists adds IF NOT EXISTS to the query
func (b CreateBuilder) ifNotExists() CreateBuilder {
return builder.Set(b, "IfNotExists", true).(CreateBuilder)
}

Expand Down
4 changes: 2 additions & 2 deletions drop.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ func init() {
}

// DropTable sets which table to be dropped
func (b DropBuilder) DropTable(name string) DropBuilder {
func (b DropBuilder) dropTable(name string) DropBuilder {
return builder.Set(b, "TableName", name).(DropBuilder)
}

func (b DropBuilder) IfExists() DropBuilder {
func (b DropBuilder) ifExists() DropBuilder {
return builder.Set(b, "IfExists", true).(DropBuilder)
}

Expand Down
3 changes: 0 additions & 3 deletions has.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import (
"github.com/lann/builder"
)

// TODO - The whole file is a todo
// Meant to find two things: HasTable and HasColumn(s)

type HasBuilder builder.Builder

type hasData struct {
Expand Down
8 changes: 4 additions & 4 deletions rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ func init() {
builder.Register(RenameBuilder{}, renameData{})
}

// From sets existing table name
func (b RenameBuilder) From(name string) RenameBuilder {
// from sets existing table name
func (b RenameBuilder) from(name string) RenameBuilder {
return builder.Set(b, "From", name).(RenameBuilder)
}

// To sets desired table name
func (b RenameBuilder) To(name string) RenameBuilder {
// to sets desired table name
func (b RenameBuilder) to(name string) RenameBuilder {
return builder.Set(b, "To", name).(RenameBuilder)
}

Expand Down
2 changes: 1 addition & 1 deletion truncate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func init() {
}

// Truncate sets which table to be dropped
func (b TruncateBuilder) Truncate(name string) TruncateBuilder {
func (b TruncateBuilder) truncate(name string) TruncateBuilder {
return builder.Set(b, "TableName", name).(TruncateBuilder)
}

Expand Down

0 comments on commit 49cf645

Please sign in to comment.