forked from sqlc-dev/sqlc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.go
More file actions
37 lines (33 loc) · 834 Bytes
/
utils.go
File metadata and controls
37 lines (33 loc) · 834 Bytes
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
package sqlite
import (
"github.com/sqlc-dev/sqlc/internal/engine/sqlite/parser"
"github.com/sqlc-dev/sqlc/internal/sql/ast"
)
type tableNamer interface {
Table_name() parser.ITable_nameContext
Schema_name() parser.ISchema_nameContext
}
func parseTableName(c tableNamer) *ast.TableName {
name := ast.TableName{
Name: identifier(c.Table_name().GetText()),
}
if c.Schema_name() != nil {
name.Schema = c.Schema_name().GetText()
}
return &name
}
func hasNotNullConstraint(checks []parser.IColumn_constraintContext) bool {
for i := range checks {
constraint, ok := checks[i].(*parser.Column_constraintContext)
if !ok {
continue
}
if constraint.PRIMARY_() != nil && constraint.KEY_() != nil {
return true
}
if constraint.NOT_() != nil && constraint.NULL_() != nil {
return true
}
}
return false
}