forked from skeema/tengo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tengo.go
38 lines (32 loc) · 1.12 KB
/
tengo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Package tengo (Go La Tengo) is a database automation library. In its current
// form, its functionality is focused on MySQL schema introspection and
// diff'ing. Future releases will add more general-purpose automation features.
package tengo
import (
"fmt"
"strings"
)
// ObjectType defines a class of object in a relational database system.
type ObjectType string
// Constants enumerating valid object types.
// Currently we do not define separate types for sub-types such as columns,
// indexes, foreign keys, etc as these are handled within the table logic.
const (
ObjectTypeDatabase ObjectType = "database"
ObjectTypeTable ObjectType = "table"
ObjectTypeProc ObjectType = "procedure"
ObjectTypeFunc ObjectType = "function"
)
// Caps returns the object type as an uppercase string.
func (ot ObjectType) Caps() string {
return strings.ToUpper(string(ot))
}
// ObjectKey is useful as a map key for indexing database objects within a
// single schema.
type ObjectKey struct {
Type ObjectType
Name string
}
func (key ObjectKey) String() string {
return fmt.Sprintf("%s %s", key.Type, EscapeIdentifier(key.Name))
}