forked from sqlc-dev/sqlc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodegen.proto
More file actions
212 lines (180 loc) · 4.4 KB
/
codegen.proto
File metadata and controls
212 lines (180 loc) · 4.4 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
syntax = "proto3";
package plugin;
option go_package = "github.com/kyleconroy/sqlc/internal/plugin";
message File
{
string name = 1 [json_name="name"];
bytes contents = 2 [json_name="contents"];
}
message Override {
// name of the type to use, e.g. `github.com/segmentio/ksuid.KSUID` or `mymodule.Type`
string code_type = 1 [json_name="code_type"];
// name of the type to use, e.g. `text`
string db_type = 3 [json_name="db_type"];
// True if the override should apply to a nullable database type
bool nullable = 5 [json_name="nullable"];
// fully qualified name of the column, e.g. `accounts.id`
string column = 6 [json_name="column"];
Identifier table = 7 [json_name="table"];
string column_name = 8 [json_name="column_name"];
PythonType python_type = 9;
ParsedGoType go_type = 10;
}
message PythonType
{
string module = 1;
string name = 2;
}
message ParsedGoType
{
string import_path = 1;
string package = 2;
string type_name = 3;
bool basic_type = 4;
map<string, string> struct_tags = 5;
}
message Settings
{
string version = 1 [json_name="version"];
string engine = 2 [json_name="engine"];
repeated string schema = 3 [json_name="schema"];
repeated string queries = 4 [json_name="queries"];
map<string, string> rename = 5 [json_name="rename"];
repeated Override overrides = 6 [json_name="overrides"];
Codegen codegen = 12 [json_name="codegen"];
// TODO: Refactor codegen settings
PythonCode python = 8;
KotlinCode kotlin = 9;
GoCode go = 10;
JSONCode json = 11;
}
message Codegen
{
string out = 1 [json_name="out"];
string plugin = 2 [json_name="plugin"];
bytes options = 3 [json_name="options"];
}
message PythonCode
{
bool emit_exact_table_names = 1;
bool emit_sync_querier = 2;
bool emit_async_querier = 3;
string package = 4;
string out = 5;
bool emit_pydantic_models = 6;
}
message KotlinCode
{
bool emit_exact_table_names = 1;
string package = 2;
string out = 3;
}
message GoCode
{
bool emit_interface = 1;
bool emit_json_tags = 2;
bool emit_db_tags = 3;
bool emit_prepared_queries = 4;
bool emit_exact_table_names = 5;
bool emit_empty_slices = 6;
bool emit_exported_queries = 7;
bool emit_result_struct_pointers = 8;
bool emit_params_struct_pointers = 9;
bool emit_methods_with_db_argument = 10;
string json_tags_case_style = 11;
string package = 12;
string out = 13;
string sql_package = 14;
string output_db_file_name = 15;
string output_models_file_name = 16;
string output_querier_file_name = 17;
string output_files_suffix = 18;
bool emit_enum_valid_method = 19;
bool emit_all_enum_values = 20;
}
message JSONCode
{
string out = 1;
string indent = 2;
string filename = 3;
}
message Catalog
{
string comment = 1;
string default_schema = 2;
string name = 3;
repeated Schema schemas = 4;
}
message Schema
{
string comment = 1;
string name = 2;
repeated Table tables = 3;
repeated Enum enums = 4;
repeated CompositeType composite_types = 5;
}
message CompositeType
{
string name = 1;
string comment = 2;
}
message Enum
{
string name = 1;
repeated string vals = 2;
string comment = 3;
}
message Table
{
Identifier rel = 1;
repeated Column columns = 2;
string comment = 3;
}
message Identifier
{
string catalog = 1;
string schema = 2;
string name = 3;
}
message Column
{
string name = 1;
bool not_null = 3;
bool is_array = 4;
string comment = 5;
int32 length = 6;
bool is_named_param = 7;
bool is_func_call = 8;
// XXX: Figure out what PostgreSQL calls `foo.id`
string scope = 9;
Identifier table = 10;
string table_alias = 11;
Identifier type = 12;
}
message Query
{
string text = 1 [json_name="text"];
string name = 2 [json_name="name"];
string cmd = 3 [json_name="cmd"];
repeated Column columns = 4 [json_name="columns"];
repeated Parameter params = 5 [json_name="parameters"];
repeated string comments = 6 [json_name="comments"];
string filename = 7 [json_name="filename"];
Identifier insert_into_table = 8 [json_name="insert_into_table"];
}
message Parameter
{
int32 number = 1 [json_name="number"];
Column column = 2 [json_name="column"];
}
message CodeGenRequest
{
Settings settings = 1 [json_name="settings"];
Catalog catalog = 2 [json_name="catalog"];
repeated Query queries = 3 [json_name="queries"];
string sqlc_version = 4 [json_name="sqlc_version"];
}
message CodeGenResponse
{
repeated File files = 1 [json_name="files"];
}