Add northwind db.
This commit is contained in:
parent
57added50a
commit
0a417a14d6
5 changed files with 139327 additions and 1 deletions
|
|
@ -49,7 +49,11 @@ func Generate(destDir string, genData DBConnection) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(" FOUND", len(schemaInfo.TableInfos), " table(s), ", len(schemaInfo.EnumInfos), " enum(s)")
|
fmt.Println(" FOUND", len(schemaInfo.TableInfos), "table(s), ", len(schemaInfo.EnumInfos), "enum(s)")
|
||||||
|
|
||||||
|
if len(schemaInfo.TableInfos) == 0 && len(schemaInfo.EnumInfos) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
schemaGenPath := path.Join(destDir, genData.DBName, genData.SchemaName)
|
schemaGenPath := path.Join(destDir, genData.DBName, genData.SchemaName)
|
||||||
fmt.Println("Destination directory:", schemaGenPath)
|
fmt.Println("Destination directory:", schemaGenPath)
|
||||||
|
|
|
||||||
3912
tests/init/data/northwind.sql
Normal file
3912
tests/init/data/northwind.sql
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -24,6 +24,7 @@ func main() {
|
||||||
"dvds",
|
"dvds",
|
||||||
"test_sample",
|
"test_sample",
|
||||||
"chinook",
|
"chinook",
|
||||||
|
"northwind",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, schemaName := range schemaNames {
|
for _, schemaName := range schemaNames {
|
||||||
|
|
@ -33,6 +34,8 @@ func main() {
|
||||||
|
|
||||||
_, err = db.Exec(string(testSampleSql))
|
_, err = db.Exec(string(testSampleSql))
|
||||||
|
|
||||||
|
panicOnError(err)
|
||||||
|
|
||||||
err = postgres.Generate("./.gentestdata", postgres.DBConnection{
|
err = postgres.Generate("./.gentestdata", postgres.DBConnection{
|
||||||
Host: dbconfig.Host,
|
Host: dbconfig.Host,
|
||||||
Port: "5432",
|
Port: "5432",
|
||||||
|
|
|
||||||
68
tests/northwind_test.go
Normal file
68
tests/northwind_test.go
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
package tests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/go-jet/jet/tests/.gentestdata/jetdb/northwind/model"
|
||||||
|
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/northwind/table"
|
||||||
|
"gotest.tools/assert"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNorthwindJoinEverything(t *testing.T) {
|
||||||
|
|
||||||
|
stmt := Customers.
|
||||||
|
LEFT_JOIN(CustomerCustomerDemo, Customers.CustomerID.EQ(CustomerCustomerDemo.CustomerID)).
|
||||||
|
LEFT_JOIN(CustomerDemographics, CustomerCustomerDemo.CustomerTypeID.EQ(CustomerDemographics.CustomerTypeID)).
|
||||||
|
LEFT_JOIN(Orders, Orders.CustomerID.EQ(Customers.CustomerID)).
|
||||||
|
LEFT_JOIN(Shippers, Orders.ShipVia.EQ(Shippers.ShipperID)).
|
||||||
|
LEFT_JOIN(OrderDetails, Orders.OrderID.EQ(OrderDetails.OrderID)).
|
||||||
|
LEFT_JOIN(Products, OrderDetails.ProductID.EQ(Products.ProductID)).
|
||||||
|
LEFT_JOIN(Categories, Products.CategoryID.EQ(Categories.CategoryID)).
|
||||||
|
LEFT_JOIN(Suppliers, Products.SupplierID.EQ(Suppliers.SupplierID)).
|
||||||
|
LEFT_JOIN(Employees, Orders.EmployeeID.EQ(Employees.EmployeeID)).
|
||||||
|
LEFT_JOIN(EmployeeTerritories, EmployeeTerritories.EmployeeID.EQ(Employees.EmployeeID)).
|
||||||
|
LEFT_JOIN(Territories, EmployeeTerritories.TerritoryID.EQ(Territories.TerritoryID)).
|
||||||
|
LEFT_JOIN(Region, Territories.RegionID.EQ(Region.RegionID)).
|
||||||
|
SELECT(
|
||||||
|
Customers.AllColumns,
|
||||||
|
CustomerDemographics.AllColumns,
|
||||||
|
Orders.AllColumns,
|
||||||
|
Shippers.AllColumns,
|
||||||
|
OrderDetails.AllColumns,
|
||||||
|
Products.AllColumns,
|
||||||
|
Categories.AllColumns,
|
||||||
|
Suppliers.AllColumns,
|
||||||
|
).
|
||||||
|
ORDER_BY(Customers.CustomerID, Orders.OrderID, Products.ProductID)
|
||||||
|
|
||||||
|
var dest []struct {
|
||||||
|
model.Customers
|
||||||
|
|
||||||
|
Demographics model.CustomerDemographics
|
||||||
|
|
||||||
|
Orders []struct {
|
||||||
|
model.Orders
|
||||||
|
|
||||||
|
Shipper model.Shippers
|
||||||
|
|
||||||
|
Details struct {
|
||||||
|
model.OrderDetails
|
||||||
|
|
||||||
|
Products []struct {
|
||||||
|
model.Products
|
||||||
|
|
||||||
|
Category model.Categories
|
||||||
|
Supplier model.Suppliers
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err := stmt.Query(db, &dest)
|
||||||
|
assert.NilError(t, err)
|
||||||
|
|
||||||
|
fmt.Println(len(dest))
|
||||||
|
|
||||||
|
//jsonSave("./testdata/northwind-all.json", dest)
|
||||||
|
assertJsonFile(t, "./testdata/northwind-all.json", dest)
|
||||||
|
}
|
||||||
135339
tests/testdata/northwind-all.json
vendored
Normal file
135339
tests/testdata/northwind-all.json
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue