Skip to content

Commit 0d3508d

Browse files
authored
fix(engine/mysql): Support nullable fields in joins for MySQL engine (#1249)
* Fix nullable fields in joins for MySQL engine
1 parent 63a755d commit 0d3508d

File tree

18 files changed

+38
-130
lines changed

18 files changed

+38
-130
lines changed

examples/booktest/mysql/db_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build examples
12
// +build examples
23

34
package booktest
@@ -150,7 +151,7 @@ func TestBooks(t *testing.T) {
150151
t.Fatal(err)
151152
}
152153
for _, ab := range res {
153-
t.Logf("Book %d: '%s', Author: '%s', ISBN: '%s' Tags: '%v'\n", ab.BookID, ab.Title, ab.Name, ab.Isbn, ab.Tags)
154+
t.Logf("Book %d: '%s', Author: '%s', ISBN: '%s' Tags: '%v'\n", ab.BookID, ab.Title, ab.Name.String, ab.Isbn, ab.Tags)
154155
}
155156

156157
// TODO: call say_hello(varchar)

examples/booktest/mysql/query.sql.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/kotlin/src/main/kotlin/com/example/booktest/mysql/QueriesImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ WHERE tags = ?
2222
data class BooksByTagsRow (
2323
val bookId: Int,
2424
val title: String,
25-
val name: String,
25+
val name: String?,
2626
val isbn: String,
2727
val tags: String
2828
)

internal/compiler/output_columns.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,14 @@ func isTableRequired(n ast.Node, tableName string, prior int) int {
302302
case ast.JoinTypeFull:
303303
return helper(tableOptional, tableOptional)
304304
}
305+
case *ast.List:
306+
for _, item := range n.Items {
307+
if res := isTableRequired(item, tableName, prior); res != tableNotFound {
308+
return res
309+
}
310+
}
305311
}
312+
306313
return tableNotFound
307314
}
308315

internal/endtoend/testdata/join_full/mysql/go/db.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

internal/endtoend/testdata/join_full/mysql/go/models.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

internal/endtoend/testdata/join_full/mysql/go/query.sql.go

Lines changed: 0 additions & 45 deletions
This file was deleted.

internal/endtoend/testdata/join_full/mysql/query.sql

Lines changed: 0 additions & 8 deletions
This file was deleted.

internal/endtoend/testdata/join_full/mysql/sqlc.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

internal/endtoend/testdata/join_left/mysql/go/query.sql.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)