Add more UseSchema tests.

Rename newly generated file to avoid potentional conflict with tables named table or views named view.
This commit is contained in:
go-jet 2023-04-02 13:58:44 +02:00
parent a9aa25416a
commit 5e34bef288
10 changed files with 250 additions and 160 deletions

View file

@ -883,6 +883,36 @@ ORDER BY "first10Artist"."Artist.ArtistId";
require.Equal(t, dest[0].Album[0].Title, "Plays Metallica By Four Cellos")
}
func TestUseSchema(t *testing.T) {
UseSchema("chinook2")
defer UseSchema("chinook")
stmt := SELECT(
Artist.AllColumns,
).FROM(
Artist,
).WHERE(Artist.ArtistId.EQ(Int(11)))
testutils.AssertDebugStatementSql(t, stmt, `
SELECT "Artist"."ArtistId" AS "Artist.ArtistId",
"Artist"."Name" AS "Artist.Name"
FROM chinook2."Artist"
WHERE "Artist"."ArtistId" = 11;
`)
var artist model.Artist
err := stmt.Query(db, &artist)
require.NoError(t, err)
testutils.AssertJSON(t, artist, `
{
"ArtistId": 11,
"Name": "Black Label Society"
}
`)
}
func TestMultiTenantSameSchemaDifferentTablePrefix(t *testing.T) {
var selectAlbumsFrom = func(tenant string) SelectStatement {