Skip to content

Commit 9d6c3c5

Browse files
add collapse to DB docs (#228)
1 parent ec6a5a6 commit 9d6c3c5

File tree

6 files changed

+234
-94
lines changed

6 files changed

+234
-94
lines changed

README.md

+115-46
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,22 @@ More info can be found in [here](https://docs.sqlc.dev/en/stable/reference/query
9292

9393
More info can be found in [here](https://docs.sqlc.dev/en/stable/reference/macros.html#macros).
9494
# PostgresSQL
95-
## :execlastid - Implementation
95+
<details>
96+
<summary>:execlastid - Implementation</summary>
97+
9698
Implemented via a `RETURNING` clause, allowing the `INSERT` command to return the newly created id, which can be of any
9799
data type that can have a unique constraint.
100+
</details>
101+
102+
<details>
103+
<summary>:copyfrom - Implementation</summary>
98104

99-
## :copyfrom - Implementation
100105
Implemented via the `COPY FROM` command which can load binary data directly from `stdin`.
106+
</details>
107+
108+
<details>
109+
<summary>Supported Data Types</summary>
101110

102-
## Data Types
103111
Since in batch insert the data is not validated by the SQL itself but written in a binary format,
104112
we consider support for the different data types separately for batch inserts and everything else.
105113

@@ -141,9 +149,13 @@ we consider support for the different data types separately for batch inserts an
141149
| json | ❌ | ❌ |
142150
| jsonb | ❌ | ❌ |
143151
| jsonpath | ❌ | ❌ |
152+
153+
</details>
154+
144155
# MySQL
156+
<details>
157+
<summary>:execlastid - Implementation</summary>
145158

146-
## :execlastid - Implementation
147159
The implementation differs if we're using `Dapper` or not.
148160

149161
### Driver - MySqlConnector
@@ -165,14 +177,20 @@ appended to the original query like this:
165177
INSERT INTO tab1 (field1, field2) VALUES ('a', 1);
166178
SELECT LAST_INSERT_ID();
167179
```
168-
169180
The generated method will return `int` & `long` for `serial` & `bigserial` respectively.
170181

171-
## :copyfrom - Implementation
182+
</details>
183+
184+
<details>
185+
<summary>:copyfrom - Implementation</summary>
172186
Implemented via the `LOAD DATA` command which can load data from a `CSV` file to a table.
173187
Requires us to first save the input batch as a CSV, and then load it via the driver.
174188

175-
## Data Types
189+
</details>
190+
191+
<details>
192+
<summary>Supported Data Types</summary>
193+
176194
Since in batch insert the data is not validated by the SQL itself but written and read from a CSV,
177195
we consider support for the different data types separately for batch inserts and everything else.
178196

@@ -216,7 +234,12 @@ we consider support for the different data types separately for batch inserts an
216234
| multilinestring | ❌ | ❌ |
217235
| multipolygon | ❌ | ❌ |
218236
| geometrycollection | ❌ | ❌ |
237+
238+
</details>
239+
219240
# SQLite3
241+
<details>
242+
<summary>:execlastid - Implementation</summary>
220243

221244
## :execlastid - Implementation
222245
Implemented via a `RETURNING` clause, allowing the `INSERT` command to return the newly created id, which can be of any
@@ -226,7 +249,10 @@ data type that can have a unique constraint.
226249
INSERT INTO tab1 (field1, field2) VALUES ('a', 1) RETURNING id_field;
227250
```
228251

229-
## :copyfrom - Implementation
252+
</details>
253+
254+
<details>
255+
<summary>:copyfrom - Implementation</summary>
230256
Implemented via a multi `VALUES` clause, like this:
231257

232258
```sql
@@ -236,14 +262,21 @@ INSERT INTO tab1 (field1, field2) VALUES
236262
('c', 3);
237263
```
238264

239-
## Data Types
265+
</details>
266+
267+
<details>
268+
<summary>Supported Data Types</summary>
240269

241270
| DB Type | Supported? |
242271
|---------|------------|
243272
| integer | ✅ |
244273
| real | ✅ |
245274
| text | ✅ |
246-
| blob | ✅ |# Contributing
275+
| blob | ✅ |
276+
277+
</details>
278+
279+
# Contributing
247280
## Local plugin development
248281
### Prerequisites
249282
Make sure that the following applications are installed and added to your path.
@@ -286,135 +319,171 @@ By default, the release script will bump the patch version. Adding `[release]` t
286319
### Release structure
287320
The new created tag will create a draft release with it, in the release there will be the wasm plugin embedded in the release. <br/>
288321
# Examples
289-
## Engine `postgresql`: [NpgsqlExample](examples/NpgsqlExample)
322+
<details>
323+
<summary>Npgsql</summary>
290324
325+
## Engine `postgresql`: [NpgsqlExample](examples/NpgsqlExample)
291326
### [Schema](examples/config/postgresql/schema.sql) | [Queries](examples/config/postgresql/query.sql) | [End2End Test](end2end/EndToEndTests/NpgsqlTester.cs)
292-
293327
### Config
294328
```yaml
295329
useDapper: false
296330
targetFramework: net8.0
297331
generateCsproj: true
298332
namespaceName: NpgsqlExampleGen
299-
```
300-
## Engine `postgresql`: [NpgsqlDapperExample](examples/NpgsqlDapperExample)
333+
```
301334

302-
### [Schema](examples/config/postgresql/schema.sql) | [Queries](examples/config/postgresql/query.sql) | [End2End Test](end2end/EndToEndTests/NpgsqlDapperTester.cs)
335+
</details>
336+
<details>
337+
<summary>NpgsqlDapper</summary>
303338

339+
## Engine `postgresql`: [NpgsqlDapperExample](examples/NpgsqlDapperExample)
340+
### [Schema](examples/config/postgresql/schema.sql) | [Queries](examples/config/postgresql/query.sql) | [End2End Test](end2end/EndToEndTests/NpgsqlDapperTester.cs)
304341
### Config
305342
```yaml
306343
useDapper: true
307344
targetFramework: net8.0
308345
generateCsproj: true
309346
namespaceName: NpgsqlDapperExampleGen
310-
```
311-
## Engine `postgresql`: [NpgsqlLegacyExample](examples/NpgsqlLegacyExample)
347+
```
312348
313-
### [Schema](examples/config/postgresql/schema.sql) | [Queries](examples/config/postgresql/query.sql) | [End2End Test](end2end/EndToEndTestsLegacy/NpgsqlTester.cs)
349+
</details>
350+
<details>
351+
<summary>NpgsqlLegacy</summary>
314352
353+
## Engine `postgresql`: [NpgsqlLegacyExample](examples/NpgsqlLegacyExample)
354+
### [Schema](examples/config/postgresql/schema.sql) | [Queries](examples/config/postgresql/query.sql) | [End2End Test](end2end/EndToEndTestsLegacy/NpgsqlTester.cs)
315355
### Config
316356
```yaml
317357
useDapper: false
318358
targetFramework: netstandard2.0
319359
generateCsproj: true
320360
namespaceName: NpgsqlLegacyExampleGen
321-
```
322-
## Engine `postgresql`: [NpgsqlDapperLegacyExample](examples/NpgsqlDapperLegacyExample)
361+
```
323362

324-
### [Schema](examples/config/postgresql/schema.sql) | [Queries](examples/config/postgresql/query.sql) | [End2End Test](end2end/EndToEndTestsLegacy/NpgsqlDapperTester.cs)
363+
</details>
364+
<details>
365+
<summary>NpgsqlDapperLegacy</summary>
325366

367+
## Engine `postgresql`: [NpgsqlDapperLegacyExample](examples/NpgsqlDapperLegacyExample)
368+
### [Schema](examples/config/postgresql/schema.sql) | [Queries](examples/config/postgresql/query.sql) | [End2End Test](end2end/EndToEndTestsLegacy/NpgsqlDapperTester.cs)
326369
### Config
327370
```yaml
328371
useDapper: true
329372
targetFramework: netstandard2.0
330373
generateCsproj: true
331374
namespaceName: NpgsqlDapperLegacyExampleGen
332-
```
333-
## Engine `mysql`: [MySqlConnectorExample](examples/MySqlConnectorExample)
375+
```
334376

335-
### [Schema](examples/config/mysql/schema.sql) | [Queries](examples/config/mysql/query.sql) | [End2End Test](end2end/EndToEndTests/MySqlConnectorTester.cs)
377+
</details>
378+
<details>
379+
<summary>MySqlConnector</summary>
336380

381+
## Engine `mysql`: [MySqlConnectorExample](examples/MySqlConnectorExample)
382+
### [Schema](examples/config/mysql/schema.sql) | [Queries](examples/config/mysql/query.sql) | [End2End Test](end2end/EndToEndTests/MySqlConnectorTester.cs)
337383
### Config
338384
```yaml
339385
useDapper: false
340386
targetFramework: net8.0
341387
generateCsproj: true
342388
namespaceName: MySqlConnectorExampleGen
343-
```
344-
## Engine `mysql`: [MySqlConnectorDapperExample](examples/MySqlConnectorDapperExample)
389+
```
345390

346-
### [Schema](examples/config/mysql/schema.sql) | [Queries](examples/config/mysql/query.sql) | [End2End Test](end2end/EndToEndTests/MySqlConnectorDapperTester.cs)
391+
</details>
392+
<details>
393+
<summary>MySqlConnectorDapper</summary>
347394

395+
## Engine `mysql`: [MySqlConnectorDapperExample](examples/MySqlConnectorDapperExample)
396+
### [Schema](examples/config/mysql/schema.sql) | [Queries](examples/config/mysql/query.sql) | [End2End Test](end2end/EndToEndTests/MySqlConnectorDapperTester.cs)
348397
### Config
349398
```yaml
350399
useDapper: true
351400
targetFramework: net8.0
352401
generateCsproj: true
353402
namespaceName: MySqlConnectorDapperExampleGen
354-
```
355-
## Engine `mysql`: [MySqlConnectorLegacyExample](examples/MySqlConnectorLegacyExample)
403+
```
356404

357-
### [Schema](examples/config/mysql/schema.sql) | [Queries](examples/config/mysql/query.sql) | [End2End Test](end2end/EndToEndTestsLegacy/MySqlConnectorTester.cs)
405+
</details>
406+
<details>
407+
<summary>MySqlConnectorLegacy</summary>
358408

409+
## Engine `mysql`: [MySqlConnectorLegacyExample](examples/MySqlConnectorLegacyExample)
410+
### [Schema](examples/config/mysql/schema.sql) | [Queries](examples/config/mysql/query.sql) | [End2End Test](end2end/EndToEndTestsLegacy/MySqlConnectorTester.cs)
359411
### Config
360412
```yaml
361413
useDapper: false
362414
targetFramework: netstandard2.0
363415
generateCsproj: true
364416
namespaceName: MySqlConnectorLegacyExampleGen
365-
```
366-
## Engine `mysql`: [MySqlConnectorDapperLegacyExample](examples/MySqlConnectorDapperLegacyExample)
417+
```
367418

368-
### [Schema](examples/config/mysql/schema.sql) | [Queries](examples/config/mysql/query.sql) | [End2End Test](end2end/EndToEndTestsLegacy/MySqlConnectorDapperTester.cs)
419+
</details>
420+
<details>
421+
<summary>MySqlConnectorDapperLegacy</summary>
369422

423+
## Engine `mysql`: [MySqlConnectorDapperLegacyExample](examples/MySqlConnectorDapperLegacyExample)
424+
### [Schema](examples/config/mysql/schema.sql) | [Queries](examples/config/mysql/query.sql) | [End2End Test](end2end/EndToEndTestsLegacy/MySqlConnectorDapperTester.cs)
370425
### Config
371426
```yaml
372427
useDapper: true
373428
targetFramework: netstandard2.0
374429
generateCsproj: true
375430
namespaceName: MySqlConnectorDapperLegacyExampleGen
376-
```
377-
## Engine `sqlite`: [SqliteExample](examples/SqliteExample)
431+
```
378432

379-
### [Schema](examples/config/sqlite/schema.sql) | [Queries](examples/config/sqlite/query.sql) | [End2End Test](end2end/EndToEndTests/SqliteTester.cs)
433+
</details>
434+
<details>
435+
<summary>Sqlite</summary>
380436

437+
## Engine `sqlite`: [SqliteExample](examples/SqliteExample)
438+
### [Schema](examples/config/sqlite/schema.sql) | [Queries](examples/config/sqlite/query.sql) | [End2End Test](end2end/EndToEndTests/SqliteTester.cs)
381439
### Config
382440
```yaml
383441
useDapper: false
384442
targetFramework: net8.0
385443
generateCsproj: true
386444
namespaceName: SqliteExampleGen
387-
```
388-
## Engine `sqlite`: [SqliteDapperExample](examples/SqliteDapperExample)
445+
```
389446

390-
### [Schema](examples/config/sqlite/schema.sql) | [Queries](examples/config/sqlite/query.sql) | [End2End Test](end2end/EndToEndTests/SqliteDapperTester.cs)
447+
</details>
448+
<details>
449+
<summary>SqliteDapper</summary>
391450

451+
## Engine `sqlite`: [SqliteDapperExample](examples/SqliteDapperExample)
452+
### [Schema](examples/config/sqlite/schema.sql) | [Queries](examples/config/sqlite/query.sql) | [End2End Test](end2end/EndToEndTests/SqliteDapperTester.cs)
392453
### Config
393454
```yaml
394455
useDapper: true
395456
targetFramework: net8.0
396457
generateCsproj: true
397458
namespaceName: SqliteDapperExampleGen
398-
```
399-
## Engine `sqlite`: [SqliteLegacyExample](examples/SqliteLegacyExample)
459+
```
400460

401-
### [Schema](examples/config/sqlite/schema.sql) | [Queries](examples/config/sqlite/query.sql) | [End2End Test](end2end/EndToEndTestsLegacy/SqliteTester.cs)
461+
</details>
462+
<details>
463+
<summary>SqliteLegacy</summary>
402464

465+
## Engine `sqlite`: [SqliteLegacyExample](examples/SqliteLegacyExample)
466+
### [Schema](examples/config/sqlite/schema.sql) | [Queries](examples/config/sqlite/query.sql) | [End2End Test](end2end/EndToEndTestsLegacy/SqliteTester.cs)
403467
### Config
404468
```yaml
405469
useDapper: false
406470
targetFramework: netstandard2.0
407471
generateCsproj: true
408472
namespaceName: SqliteLegacyExampleGen
409-
```
410-
## Engine `sqlite`: [SqliteDapperLegacyExample](examples/SqliteDapperLegacyExample)
473+
```
411474

412-
### [Schema](examples/config/sqlite/schema.sql) | [Queries](examples/config/sqlite/query.sql) | [End2End Test](end2end/EndToEndTestsLegacy/SqliteDapperTester.cs)
475+
</details>
476+
<details>
477+
<summary>SqliteDapperLegacy</summary>
413478

479+
## Engine `sqlite`: [SqliteDapperLegacyExample](examples/SqliteDapperLegacyExample)
480+
### [Schema](examples/config/sqlite/schema.sql) | [Queries](examples/config/sqlite/query.sql) | [End2End Test](end2end/EndToEndTestsLegacy/SqliteDapperTester.cs)
414481
### Config
415482
```yaml
416483
useDapper: true
417484
targetFramework: netstandard2.0
418485
generateCsproj: true
419486
namespaceName: SqliteDapperLegacyExampleGen
420-
```
487+
```
488+
489+
</details>

docs/04_Postgres.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
# PostgresSQL
2-
## :execlastid - Implementation
2+
<details>
3+
<summary>:execlastid - Implementation</summary>
4+
35
Implemented via a `RETURNING` clause, allowing the `INSERT` command to return the newly created id, which can be of any
46
data type that can have a unique constraint.
7+
</details>
8+
9+
<details>
10+
<summary>:copyfrom - Implementation</summary>
511

6-
## :copyfrom - Implementation
712
Implemented via the `COPY FROM` command which can load binary data directly from `stdin`.
13+
</details>
14+
15+
<details>
16+
<summary>Supported Data Types</summary>
817

9-
## Data Types
1018
Since in batch insert the data is not validated by the SQL itself but written in a binary format,
1119
we consider support for the different data types separately for batch inserts and everything else.
1220

@@ -48,3 +56,6 @@ we consider support for the different data types separately for batch inserts an
4856
| json |||
4957
| jsonb |||
5058
| jsonpath |||
59+
60+
</details>
61+

docs/05_MySql.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# MySQL
2+
<details>
3+
<summary>:execlastid - Implementation</summary>
24

3-
## :execlastid - Implementation
45
The implementation differs if we're using `Dapper` or not.
56

67
### Driver - MySqlConnector
@@ -22,14 +23,20 @@ appended to the original query like this:
2223
INSERT INTO tab1 (field1, field2) VALUES ('a', 1);
2324
SELECT LAST_INSERT_ID();
2425
```
25-
2626
The generated method will return `int` & `long` for `serial` & `bigserial` respectively.
2727

28-
## :copyfrom - Implementation
28+
</details>
29+
30+
<details>
31+
<summary>:copyfrom - Implementation</summary>
2932
Implemented via the `LOAD DATA` command which can load data from a `CSV` file to a table.
3033
Requires us to first save the input batch as a CSV, and then load it via the driver.
3134

32-
## Data Types
35+
</details>
36+
37+
<details>
38+
<summary>Supported Data Types</summary>
39+
3340
Since in batch insert the data is not validated by the SQL itself but written and read from a CSV,
3441
we consider support for the different data types separately for batch inserts and everything else.
3542

@@ -73,3 +80,6 @@ we consider support for the different data types separately for batch inserts an
7380
| multilinestring |||
7481
| multipolygon |||
7582
| geometrycollection |||
83+
84+
</details>
85+

0 commit comments

Comments
 (0)