added order by table_name clause to mysql and postgres query sets
This commit is contained in:
parent
1bf48d640a
commit
9185bb8a76
3 changed files with 10 additions and 6 deletions
|
|
@ -3,10 +3,11 @@ package mysql
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/go-jet/jet/v2/generator/metadata"
|
"github.com/go-jet/jet/v2/generator/metadata"
|
||||||
"github.com/go-jet/jet/v2/internal/utils/throw"
|
"github.com/go-jet/jet/v2/internal/utils/throw"
|
||||||
"github.com/go-jet/jet/v2/qrm"
|
"github.com/go-jet/jet/v2/qrm"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// mySqlQuerySet is dialect query set for MySQL
|
// mySqlQuerySet is dialect query set for MySQL
|
||||||
|
|
@ -16,7 +17,8 @@ func (m mySqlQuerySet) GetTablesMetaData(db *sql.DB, schemaName string, tableTyp
|
||||||
query := `
|
query := `
|
||||||
SELECT table_name as "table.name"
|
SELECT table_name as "table.name"
|
||||||
FROM INFORMATION_SCHEMA.tables
|
FROM INFORMATION_SCHEMA.tables
|
||||||
WHERE table_schema = ? and table_type = ?;
|
WHERE table_schema = ? and table_type = ?
|
||||||
|
ORDER BY table_name;
|
||||||
`
|
`
|
||||||
var tables []metadata.Table
|
var tables []metadata.Table
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package postgres
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"github.com/go-jet/jet/v2/generator/metadata"
|
"github.com/go-jet/jet/v2/generator/metadata"
|
||||||
"github.com/go-jet/jet/v2/internal/utils/throw"
|
"github.com/go-jet/jet/v2/internal/utils/throw"
|
||||||
"github.com/go-jet/jet/v2/qrm"
|
"github.com/go-jet/jet/v2/qrm"
|
||||||
|
|
@ -15,7 +16,8 @@ func (p postgresQuerySet) GetTablesMetaData(db *sql.DB, schemaName string, table
|
||||||
query := `
|
query := `
|
||||||
SELECT table_name as "table.name"
|
SELECT table_name as "table.name"
|
||||||
FROM information_schema.tables
|
FROM information_schema.tables
|
||||||
WHERE table_schema = $1 and table_type = $2;
|
WHERE table_schema = $1 and table_type = $2
|
||||||
|
ORDER BY table_name;
|
||||||
`
|
`
|
||||||
var tables []metadata.Table
|
var tables []metadata.Table
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -404,20 +404,20 @@ package table
|
||||||
// returned by calling FromSchema on them. Passing an empty string to this function
|
// returned by calling FromSchema on them. Passing an empty string to this function
|
||||||
// will cause queries to be generated without any table/view alias.
|
// will cause queries to be generated without any table/view alias.
|
||||||
func UseSchema(schema string) {
|
func UseSchema(schema string) {
|
||||||
Film = Film.FromSchema(schema)
|
|
||||||
Address = Address.FromSchema(schema)
|
|
||||||
Actor = Actor.FromSchema(schema)
|
Actor = Actor.FromSchema(schema)
|
||||||
|
Address = Address.FromSchema(schema)
|
||||||
Category = Category.FromSchema(schema)
|
Category = Category.FromSchema(schema)
|
||||||
City = City.FromSchema(schema)
|
City = City.FromSchema(schema)
|
||||||
Country = Country.FromSchema(schema)
|
Country = Country.FromSchema(schema)
|
||||||
Customer = Customer.FromSchema(schema)
|
Customer = Customer.FromSchema(schema)
|
||||||
|
Film = Film.FromSchema(schema)
|
||||||
FilmActor = FilmActor.FromSchema(schema)
|
FilmActor = FilmActor.FromSchema(schema)
|
||||||
FilmCategory = FilmCategory.FromSchema(schema)
|
FilmCategory = FilmCategory.FromSchema(schema)
|
||||||
Inventory = Inventory.FromSchema(schema)
|
Inventory = Inventory.FromSchema(schema)
|
||||||
Language = Language.FromSchema(schema)
|
Language = Language.FromSchema(schema)
|
||||||
|
Payment = Payment.FromSchema(schema)
|
||||||
Rental = Rental.FromSchema(schema)
|
Rental = Rental.FromSchema(schema)
|
||||||
Staff = Staff.FromSchema(schema)
|
Staff = Staff.FromSchema(schema)
|
||||||
Payment = Payment.FromSchema(schema)
|
|
||||||
Store = Store.FromSchema(schema)
|
Store = Store.FromSchema(schema)
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue