Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
aacebo committed Nov 16, 2024
1 parent 0924ebe commit 6b9c3c3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
13 changes: 4 additions & 9 deletions box/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ a dependency injection library

```go
b := box.New()
b.Put(&ServiceA{}, &ServiceB{})

fn, err := b.Inject(func (a *ServiceA, b *Service B) {
fmt.Println(a, b)
})

if err != nil {
panic(err)
}
// put some things in the box
b.Put(&ServiceA{}, &ServiceB{})

fn()
// get something out of the box
box.Get[*ServiceA](b)
```

# Benchmarks
Expand Down
27 changes: 26 additions & 1 deletion sqlx/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,32 @@ func (self SelectStatement) Sql() string {
}

func (self SelectStatement) SqlPretty() string {
return strings.Join([]string{}, "\n")
parts := []string{"SELECT"}
columns := []string{}

for _, column := range self.columns {
columns = append(columns, column.Sql())
}

parts = append(parts, strings.Join(columns, ",\n"))

if self.from != nil {
parts = append(parts, "FROM "+self.from.Sql())
}

if self.where != nil {
parts = append(parts, "WHERE"+self.where.Sql())
}

sql := strings.Join(parts, "\n")

if self.depth == 0 {
sql += ";"
} else {
sql = fmt.Sprintf("(%s)", sql)
}

return sql
}

func (self *SelectStatement) setDepth(depth uint) {
Expand Down

0 comments on commit 6b9c3c3

Please sign in to comment.