@@ -11,16 +11,18 @@ func TestProcessTypeReplacements(t *testing.T) {
11
11
{
12
12
Columns : []drivers.Column {
13
13
{
14
- Name : "id" ,
15
- Type : "int" ,
16
- DBType : "serial" ,
17
- Default : "some db nonsense" ,
14
+ Name : "id" ,
15
+ Type : "int" ,
16
+ DBType : "serial" ,
17
+ Default : "some db nonsense" ,
18
+ Nullable : false ,
18
19
},
19
20
{
20
- Name : "name" ,
21
- Type : "null.String" ,
22
- DBType : "serial" ,
23
- Default : "some db nonsense" ,
21
+ Name : "name" ,
22
+ Type : "null.String" ,
23
+ DBType : "serial" ,
24
+ Default : "some db nonsense" ,
25
+ Nullable : true ,
24
26
},
25
27
{
26
28
Name : "domain" ,
@@ -29,41 +31,48 @@ func TestProcessTypeReplacements(t *testing.T) {
29
31
DomainName : "domain name" ,
30
32
},
31
33
{
32
- Name : "by_named" ,
33
- Type : "int" ,
34
- DBType : "numeric" ,
35
- Default : "some db nonsense" ,
34
+ Name : "by_named" ,
35
+ Type : "int" ,
36
+ DBType : "numeric" ,
37
+ Default : "some db nonsense" ,
38
+ Nullable : false ,
36
39
},
37
40
{
38
- Name : "by_comment" ,
39
- Type : "string" ,
40
- DBType : "text" ,
41
- Default : "some db nonsense" ,
42
- Comment : "xid" ,
41
+ Name : "by_comment" ,
42
+ Type : "string" ,
43
+ DBType : "text" ,
44
+ Default : "some db nonsense" ,
45
+ Nullable : false ,
46
+ Comment : "xid" ,
43
47
},
44
48
},
45
49
},
46
50
{
47
51
Key : "named_table" ,
48
52
Columns : []drivers.Column {
49
53
{
50
- Name : "id" ,
51
- Type : "int" ,
52
- DBType : "serial" ,
53
- Default : "some db nonsense" ,
54
+ Name : "id" ,
55
+ Type : "int" ,
56
+ DBType : "serial" ,
57
+ Default : "some db nonsense" ,
58
+ Nullable : false ,
54
59
},
55
60
{
56
- Name : "by_comment" ,
57
- Type : "string" ,
58
- DBType : "text" ,
59
- Default : "some db nonsense" ,
60
- Comment : "xid" ,
61
+ Name : "by_comment" ,
62
+ Type : "string" ,
63
+ DBType : "text" ,
64
+ Default : "some db nonsense" ,
65
+ Nullable : false ,
66
+ Comment : "xid" ,
61
67
},
62
68
},
63
69
},
64
70
}
65
71
66
72
types := map [string ]drivers.Type {
73
+ "excellent.Type" : {
74
+ Imports : []string {`"rock.com/excellent"` },
75
+ },
67
76
"excellent.NamedType" : {
68
77
Imports : []string {`"rock.com/excellent-name"` },
69
78
},
@@ -82,6 +91,12 @@ func TestProcessTypeReplacements(t *testing.T) {
82
91
}
83
92
84
93
replacements := []Replace {
94
+ {
95
+ Match : drivers.Column {
96
+ DBType : "serial" ,
97
+ },
98
+ Replace : "excellent.Type" ,
99
+ },
85
100
{
86
101
Tables : []string {"named_table" },
87
102
Match : drivers.Column {
@@ -91,7 +106,8 @@ func TestProcessTypeReplacements(t *testing.T) {
91
106
},
92
107
{
93
108
Match : drivers.Column {
94
- Type : "null.String" ,
109
+ Type : "null.String" ,
110
+ Nullable : true ,
95
111
},
96
112
Replace : "int" ,
97
113
},
@@ -117,7 +133,7 @@ func TestProcessTypeReplacements(t *testing.T) {
117
133
118
134
processTypeReplacements (types , replacements , tables )
119
135
120
- if typ := tables [0 ].Columns [0 ].Type ; typ != "int " {
136
+ if typ := tables [0 ].Columns [0 ].Type ; typ != "excellent.Type " {
121
137
t .Error ("type was wrong:" , typ )
122
138
}
123
139
0 commit comments