2020-08-06 20:58:47 +03:00
|
|
|
// Package sakila holds test constants and such for the sakila test sources.
|
|
|
|
package sakila
|
|
|
|
|
|
|
|
import (
|
2020-08-23 13:42:15 +03:00
|
|
|
"github.com/neilotoole/sq/libsq/core/kind"
|
2020-08-06 20:58:47 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// Sakila source handles.
|
|
|
|
const (
|
|
|
|
XLSX = "@sakila_xlsx"
|
|
|
|
XLSXSubset = "@sakila_xlsx_subset"
|
|
|
|
XLSXNoHeader = "@sakila_xlsx_noheader"
|
|
|
|
CSVActor = "@sakila_csv_actor"
|
2023-04-09 17:44:27 +03:00
|
|
|
CSVAddress = "@sakila_csv_address"
|
2020-08-06 20:58:47 +03:00
|
|
|
CSVActorHTTP = "@sakila_csv_actor_http"
|
|
|
|
CSVActorNoHeader = "@sakila_csv_actor_noheader"
|
|
|
|
TSVActor = "@sakila_tsv_actor"
|
|
|
|
TSVActorNoHeader = "@sakila_tsv_actor_noheader"
|
|
|
|
SL3 = "@sakila_sl3"
|
2023-03-22 09:17:34 +03:00
|
|
|
SL3Whitespace = "@sakila_sl3_whitespace"
|
2020-08-06 20:58:47 +03:00
|
|
|
Pg9 = "@sakila_pg9"
|
|
|
|
Pg10 = "@sakila_pg10"
|
|
|
|
Pg11 = "@sakila_pg11"
|
|
|
|
Pg12 = "@sakila_pg12"
|
|
|
|
Pg = Pg12
|
2022-12-24 07:05:26 +03:00
|
|
|
My56 = "@sakila_my56" // FIXME: rename to @sakila_my5_6
|
|
|
|
My57 = "@sakila_my57" // FIXME: rename to @sakila_my5_7
|
2020-08-06 20:58:47 +03:00
|
|
|
My8 = "@sakila_my8"
|
|
|
|
My = My8
|
|
|
|
MS17 = "@sakila_ms17"
|
2023-03-26 11:01:41 +03:00
|
|
|
MS19 = "@sakila_ms19"
|
2023-04-08 21:09:27 +03:00
|
|
|
MS = MS19
|
2020-08-06 20:58:47 +03:00
|
|
|
)
|
|
|
|
|
2020-11-02 20:40:29 +03:00
|
|
|
// AllHandles returns all the typical sakila handles. It does not
|
2020-08-09 17:40:46 +03:00
|
|
|
// include monotable handles such as @sakila_csv_actor.
|
2020-08-16 00:06:40 +03:00
|
|
|
func AllHandles() []string {
|
2023-03-26 11:01:41 +03:00
|
|
|
return []string{SL3, Pg9, Pg10, Pg11, Pg12, My56, My57, My8, MS17, MS19, XLSX}
|
2020-08-09 17:40:46 +03:00
|
|
|
}
|
2020-08-06 20:58:47 +03:00
|
|
|
|
2020-08-09 17:40:46 +03:00
|
|
|
// SQLAll returns all the sakila SQL handles.
|
|
|
|
func SQLAll() []string {
|
2023-03-26 11:01:41 +03:00
|
|
|
return []string{SL3, Pg9, Pg10, Pg11, Pg12, My56, My57, My8, MS17, MS19}
|
2020-08-09 17:40:46 +03:00
|
|
|
}
|
2020-08-06 20:58:47 +03:00
|
|
|
|
2020-08-09 17:40:46 +03:00
|
|
|
// SQLAllExternal is the same as SQLAll, but only includes
|
|
|
|
// external (non-embedded) sources. That is, it excludes SL3.
|
|
|
|
func SQLAllExternal() []string {
|
2023-03-26 11:01:41 +03:00
|
|
|
return []string{Pg9, Pg10, Pg11, Pg12, My56, My57, My8, MS17, MS19}
|
2020-08-09 17:40:46 +03:00
|
|
|
}
|
2020-08-06 20:58:47 +03:00
|
|
|
|
2020-08-09 17:40:46 +03:00
|
|
|
// SQLLatest returns the handles for the latest
|
|
|
|
// version of each supported SQL database. This is provided
|
|
|
|
// in addition to SQLAll to enable quicker iterative testing
|
|
|
|
// during development.
|
|
|
|
func SQLLatest() []string {
|
|
|
|
return []string{SL3, Pg, My, MS}
|
|
|
|
}
|
2020-08-06 20:58:47 +03:00
|
|
|
|
2020-08-09 17:40:46 +03:00
|
|
|
// PgAll returns the handles for all postgres versions.
|
|
|
|
func PgAll() []string {
|
|
|
|
return []string{Pg9, Pg10, Pg11, Pg12}
|
|
|
|
}
|
2020-08-06 20:58:47 +03:00
|
|
|
|
2020-08-09 17:40:46 +03:00
|
|
|
// MyAll returns the handles for all MySQL versions.
|
|
|
|
func MyAll() []string {
|
|
|
|
return []string{My56, My57, My8}
|
|
|
|
}
|
2020-08-06 20:58:47 +03:00
|
|
|
|
2020-08-09 17:40:46 +03:00
|
|
|
// MSAll returns the handles for all SQL Server versions.
|
|
|
|
func MSAll() []string {
|
|
|
|
return []string{MS17}
|
|
|
|
}
|
2020-08-06 20:58:47 +03:00
|
|
|
|
|
|
|
// Facts regarding the sakila database.
|
|
|
|
const (
|
|
|
|
TblActor = "actor"
|
|
|
|
TblActorCount = 200
|
2023-04-09 17:44:27 +03:00
|
|
|
TblAddress = "address"
|
|
|
|
TblAddressCount = 603
|
2020-08-06 20:58:47 +03:00
|
|
|
TblFilm = "film"
|
|
|
|
TblFilmCount = 1000
|
|
|
|
TblFilmActor = "film_actor"
|
|
|
|
TblFilmActorCount = 5462
|
|
|
|
TblPayment = "payment"
|
|
|
|
TblPaymentCount = 16049
|
|
|
|
|
|
|
|
MillerEmail = "MARIA.MILLER@sakilacustomer.org"
|
|
|
|
MillerCustID = 7
|
|
|
|
MillerAddrID = 11
|
|
|
|
MillerCityID = 280
|
|
|
|
)
|
|
|
|
|
2020-08-10 18:16:44 +03:00
|
|
|
// TblActorCols returns table "actor" column names.
|
|
|
|
func TblActorCols() []string {
|
|
|
|
return []string{"actor_id", "first_name", "last_name", "last_update"}
|
|
|
|
}
|
|
|
|
|
2020-08-24 05:32:59 +03:00
|
|
|
// TblActorColKinds returns table "actor" column kinds.
|
2020-08-23 13:42:15 +03:00
|
|
|
func TblActorColKinds() []kind.Kind {
|
|
|
|
return []kind.Kind{kind.Int, kind.Text, kind.Text, kind.Datetime}
|
2020-08-10 18:16:44 +03:00
|
|
|
}
|
|
|
|
|
2023-04-09 17:44:27 +03:00
|
|
|
// TblAddressCols returns table "address" column names.
|
|
|
|
func TblAddressCols() []string {
|
2023-04-10 04:29:13 +03:00
|
|
|
return []string{
|
|
|
|
"address_id",
|
|
|
|
"address",
|
|
|
|
"address2",
|
|
|
|
"district",
|
|
|
|
"city_id",
|
|
|
|
"postal_code",
|
|
|
|
"phone",
|
|
|
|
"last_update",
|
|
|
|
}
|
2023-04-09 17:44:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// TblAddressColKinds returns table "address" column kinds.
|
|
|
|
func TblAddressColKinds() []kind.Kind {
|
2023-04-10 04:29:13 +03:00
|
|
|
return []kind.Kind{
|
|
|
|
kind.Int, // address_id
|
|
|
|
kind.Text, // address
|
|
|
|
kind.Text, // address2
|
|
|
|
kind.Text, // district
|
|
|
|
kind.Int, // city_id
|
|
|
|
kind.Int, // postal_code
|
|
|
|
kind.Text, // phone
|
|
|
|
kind.Datetime, // last_update
|
|
|
|
}
|
2023-04-09 17:44:27 +03:00
|
|
|
}
|
|
|
|
|
2020-08-10 18:16:44 +03:00
|
|
|
// TblFilmActorCols returns table "film" column names.
|
|
|
|
func TblFilmActorCols() []string {
|
|
|
|
return []string{"actor_id", "film_id", "last_update"}
|
|
|
|
}
|
|
|
|
|
2020-08-24 05:32:59 +03:00
|
|
|
// TblFilmActorColKinds returns table "film_actor" column kinds.
|
|
|
|
func TblFilmActorColKinds() []kind.Kind {
|
|
|
|
return []kind.Kind{kind.Int, kind.Int, kind.Datetime}
|
|
|
|
}
|
|
|
|
|
2020-08-10 18:16:44 +03:00
|
|
|
// TblPaymentCols returns table "payment" column names.
|
|
|
|
func TblPaymentCols() []string {
|
|
|
|
return []string{"payment_id", "customer_id", "staff_id", "rental_id", "amount", "payment_date", "last_update"}
|
|
|
|
}
|
|
|
|
|
2020-08-24 05:32:59 +03:00
|
|
|
// TblPaymentColKinds returns table "payment" column kinds.
|
|
|
|
func TblPaymentColKinds() []kind.Kind {
|
|
|
|
return []kind.Kind{kind.Int, kind.Int, kind.Int, kind.Int, kind.Decimal, kind.Datetime, kind.Datetime}
|
|
|
|
}
|
|
|
|
|
2020-08-10 18:16:44 +03:00
|
|
|
// AllTbls returns all table names.
|
|
|
|
func AllTbls() []string {
|
2022-12-18 11:35:59 +03:00
|
|
|
return []string{
|
|
|
|
"actor", "address", "category", "city", "country", "customer", "film", "film_actor",
|
|
|
|
"film_category", "film_text", "inventory", "language", "payment", "rental", "staff", "store",
|
|
|
|
}
|
2020-08-10 18:16:44 +03:00
|
|
|
}
|
|
|
|
|
2020-08-16 00:06:40 +03:00
|
|
|
// AllTblsViews returns all table AND view names.
|
|
|
|
func AllTblsViews() []string {
|
2022-12-18 11:35:59 +03:00
|
|
|
return []string{
|
|
|
|
"actor", "address", "category", "city", "country", "customer", "customer_list", "film",
|
2022-12-18 05:43:53 +03:00
|
|
|
"film_actor", "film_category", "film_list", "film_text", "inventory", "language", "payment", "rental",
|
2022-12-18 11:35:59 +03:00
|
|
|
"sales_by_film_category", "sales_by_store", "staff", "staff_list", "store",
|
|
|
|
}
|
2020-08-16 00:06:40 +03:00
|
|
|
}
|
|
|
|
|
2020-08-10 18:16:44 +03:00
|
|
|
// AllTblsExceptFilmText exists because our current postgres image is different
|
|
|
|
// from the others in that it doesn't have the film_text table.
|
|
|
|
func AllTblsExceptFilmText() []string {
|
|
|
|
// TODO: delete AllTblsExceptFilmText when postgres image is updated to include film_text.
|
2022-12-18 11:35:59 +03:00
|
|
|
return []string{
|
|
|
|
"actor", "address", "category", "city", "country", "customer", "film", "film_actor",
|
|
|
|
"film_category", "inventory", "language", "payment", "rental", "staff", "store",
|
|
|
|
}
|
2020-08-10 18:16:44 +03:00
|
|
|
}
|
2020-08-06 20:58:47 +03:00
|
|
|
|
|
|
|
// URLs for sakila resources.
|
|
|
|
const (
|
|
|
|
URLActorCSV = "https://sq.io/testdata/actor.csv"
|
|
|
|
URLSubsetXLSX = "https://sq.io/testdata/sakila_subset.xlsx"
|
|
|
|
URLXLSX = "https://sq.io/testdata/sakila.xlsx"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Paths for sakila resources.
|
|
|
|
const (
|
|
|
|
PathSL3 = "drivers/sqlite3/testdata/sakila.db"
|
2023-03-22 09:17:34 +03:00
|
|
|
PathSL3Whitespace = "drivers/sqlite3/testdata/sakila-whitespace.db"
|
2020-08-06 20:58:47 +03:00
|
|
|
PathXLSX = "drivers/xlsx/testdata/sakila.xlsx"
|
|
|
|
PathXLSXSubset = "drivers/xlsx/testdata/sakila_subset.xlsx"
|
2020-11-02 20:40:29 +03:00
|
|
|
PathXLSXActorHeader = "drivers/xlsx/testdata/sakila_actor_header.xlsx"
|
2020-08-06 20:58:47 +03:00
|
|
|
PathCSVActor = "drivers/csv/testdata/sakila-csv/actor.csv"
|
|
|
|
PathCSVActorNoHeader = "drivers/csv/testdata/sakila-csv-noheader/actor.csv"
|
|
|
|
PathTSVActor = "drivers/csv/testdata/sakila-tsv/actor.tsv"
|
|
|
|
)
|