@@ -12,7 +12,7 @@ type SchemaJSON struct {
12
12
Relations []* RelationJSON `json:"relations,omitempty"`
13
13
Functions []* Function `json:"functions,omitempty"`
14
14
Enums []* Enum `json:"enums,omitempty"`
15
- Driver * Driver `json:"driver,omitempty"`
15
+ Driver * DriverJSON `json:"driver,omitempty"`
16
16
Labels Labels `json:"labels,omitempty"`
17
17
Viewpoints Viewpoints `json:"viewpoints,omitempty"`
18
18
}
@@ -54,6 +54,18 @@ type RelationJSON struct {
54
54
Virtual bool `json:"virtual,omitempty"`
55
55
}
56
56
57
+ type DriverJSON struct {
58
+ Name string `json:"name"`
59
+ DatabaseVersion string `json:"database_version,omitempty" yaml:"databaseVersion,omitempty"`
60
+ Meta * DriverMetaJSON `json:"meta,omitempty"`
61
+ }
62
+
63
+ type DriverMetaJSON struct {
64
+ CurrentSchema string `json:"current_schema,omitempty" yaml:"currentSchema,omitempty"`
65
+ SearchPaths []string `json:"search_paths,omitempty" yaml:"searchPaths,omitempty"`
66
+ Dict map [string ]string `json:"dict,omitempty"`
67
+ }
68
+
57
69
// ToJSONObjct convert schema.Schema to JSON object
58
70
func (s Schema ) ToJSONObject () SchemaJSON {
59
71
var tables []* TableJSON
@@ -73,7 +85,7 @@ func (s Schema) ToJSONObject() SchemaJSON {
73
85
Relations : relations ,
74
86
Functions : s .Functions ,
75
87
Enums : s .Enums ,
76
- Driver : s .Driver ,
88
+ Driver : s .Driver . ToJSONObject () ,
77
89
Labels : s .Labels ,
78
90
Viewpoints : s .Viewpoints ,
79
91
}
@@ -140,6 +152,28 @@ func (r Relation) ToJSONObject() RelationJSON {
140
152
}
141
153
}
142
154
155
+ func (d * Driver ) ToJSONObject () * DriverJSON {
156
+ if d == nil {
157
+ return nil
158
+ }
159
+ return & DriverJSON {
160
+ Name : d .Name ,
161
+ DatabaseVersion : d .DatabaseVersion ,
162
+ Meta : d .Meta .ToJSONObject (),
163
+ }
164
+ }
165
+
166
+ func (d * DriverMeta ) ToJSONObject () * DriverMetaJSON {
167
+ if d == nil {
168
+ return nil
169
+ }
170
+ return & DriverMetaJSON {
171
+ CurrentSchema : d .CurrentSchema ,
172
+ SearchPaths : d .SearchPaths ,
173
+ Dict : d .Dict .Dump (),
174
+ }
175
+ }
176
+
143
177
// MarshalJSON return custom JSON byte
144
178
func (s Schema ) MarshalJSON () ([]byte , error ) {
145
179
ss := s .ToJSONObject ()
0 commit comments