github.com/gramework/gramework@v1.8.1-0.20231027140105-82555c9057f5/x/sqlgen/create_database.go (about)

     1  package sqlgen
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  // UseIt says that we need to USE
     8  // the database we just created
     9  func (cb *CreateDatabaseBuilder) UseIt() *CreateDatabaseBuilder {
    10  	cb.useIt = true
    11  	return cb
    12  }
    13  
    14  // Build the statement
    15  func (cb *CreateDatabaseBuilder) Build() string {
    16  	q := fmt.Sprintf("CREATE DATABASE %s;", cb.name)
    17  	if cb.useIt {
    18  		q = fmt.Sprintf("%s\nUSE %s;\n", q, cb.name)
    19  	}
    20  	return q
    21  }