You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jet -dsn="file:///path/to/sqlite/database/file" -schema=dvds -path=./gen # sqlite database assumed for 'file' data sources
@@ -168,7 +166,7 @@ and _film category_ is not 'Action'.
168
166
stmt:=SELECT(
169
167
Actor.ActorID, Actor.FirstName, Actor.LastName, Actor.LastUpdate, // or just Actor.AllColumns
170
168
Film.AllColumns,
171
-
Language.AllColumns.Except(Language.LastUpdate),
169
+
Language.AllColumns.Except(Language.LastUpdate), // all language columns except last_update
172
170
Category.AllColumns,
173
171
).FROM(
174
172
Actor.
@@ -186,7 +184,7 @@ stmt := SELECT(
186
184
Film.FilmID.ASC(),
187
185
)
188
186
```
189
-
_Package(dot) import is used, so the statements would resemble as much as possible as native SQL._
187
+
_Package(dot) import is used, so the statements look as close as possible to the native SQL._
190
188
Note that every column has a type. String column `Language.Name` and `Category.Name` can be compared only with
191
189
string columns and expressions. `Actor.ActorID`, `FilmActor.ActorID`, `Film.Length` are integer columns
192
190
and can be compared only with integer columns and expressions.
@@ -245,7 +243,7 @@ __How to get debug SQL from statement?__
245
243
```go
246
244
debugSql:= stmt.DebugSql()
247
245
```
248
-
debugSql - this query string can be copy-pasted to sql editor and executed. __It is not intended to be used in production, only for the purpose of debugging!!!__
246
+
debugSql - this query string can be copy-pasted to sql editor and executed. __It is not intended to be used in production. For debug purposes only!!!__
249
247
250
248
<details>
251
249
<summary>Click to see debug sql</summary>
@@ -295,8 +293,8 @@ First we have to create desired structure to store query result.
295
293
This is done be combining autogenerated model types, or it can be done
296
294
by combining custom model types(see [wiki](https://github.com/go-jet/jet/wiki/Query-Result-Mapping-(QRM)#custom-model-types) for more information).
297
295
298
-
It's possible to overwrite default jet generator behavior, and all the aspects of generated model and SQLBuilder types can be
Let's say this is our desired structure made of autogenerated types:
302
300
```go
@@ -315,14 +313,14 @@ var dest []struct {
315
313
`Langauge` field is just a single model struct. `Film` can belong to multiple categories.
316
314
_*There is no limitation of how big or nested destination can be._
317
315
318
-
Now lets execute above statement on open database connection (or transaction) db and store result into `dest`.
316
+
Now let's execute above statement on open database connection (or transaction) db and store result into `dest`.
319
317
320
318
```go
321
319
err:= stmt.Query(db, &dest)
322
320
handleError(err)
323
321
```
324
322
325
-
__And thats it.__
323
+
__And that's it.__
326
324
327
325
`dest` now contains the list of all actors(with list of films acted, where each film has information about language and list of belonging categories) that acted in films longer than 180 minutes, film language is 'English'
328
326
and film category is not 'Action'.
@@ -528,7 +526,7 @@ The biggest benefit is speed. Speed is being improved in 3 major areas:
528
526
529
527
##### Speed of development
530
528
531
-
Writing SQL queries is faster and easier as the developers have help of SQL code completion and SQL type safety directly from Go.
529
+
Writing SQL queries is faster and easier, as developers will have help of SQL code completion and SQL type safety directly from Go code.
532
530
Automatic scan to arbitrary structure removes a lot of headache and boilerplate code needed to structure database query result.
533
531
534
532
##### Speed of execution
@@ -539,14 +537,14 @@ Thus handler time lost on latency between server and database can be constant. H
539
537
only to the query complexity and the number of rows returned from database.
540
538
541
539
With Jet, it is even possible to join the whole database and store the whole structured result in one database call.
542
-
This is exactly what is being done in one of the tests: [TestJoinEverything](/tests/postgres/chinook_db_test.go#L40).
543
-
The whole test database is joined and query result(~10,000 rows) is stored in a structured variable in less than 0.7s.
540
+
This is exactly what is being done in one of the tests: [TestJoinEverything](https://github.com/go-jet/jet/blob/6706f4b228f51cf810129f57ba90bbdb60b85fe7/tests/postgres/chinook_db_test.go#L187).
541
+
The whole test database is joined and query result(~10,000 rows) is stored in a structured variable in less than 0.5s.
544
542
545
543
##### How quickly bugs are found
546
544
547
545
The most expensive bugs are the one discovered on the production, and the least expensive are those found during development.
548
546
With automatically generated type safe SQL, not only queries are written faster but bugs are found sooner.
549
-
Letsreturn to quick start example, and take closer look at a line:
547
+
Let's return to quick start example, and take closer look at a line:
550
548
```go
551
549
AND(Film.Length.GT(Int(180))),
552
550
```
@@ -573,6 +571,8 @@ To run the tests, additional dependencies are required:
flag.StringVar(¶ms, "params", "", "Additional connection string parameters(optional). Used only if dsn is not set.")
64
65
flag.StringVar(&sslmode, "sslmode", "disable", `Whether or not to use SSL. Used only if dsn is not set. (optional)(default "disable")(PostgreSQL only)`)
65
66
flag.StringVar(&ignoreTables, "ignore-tables", "", `Comma-separated list of tables to ignore`)
0 commit comments