mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-18 13:41:49 +03:00
2ba633fc2a
* Fixed space issues with expressions * Alias can now be an arbitrary string * Alias can now be an arbitrary string (fixed) * Alias now automatically applied to expressions * Ignore .run * Fixed issue with TestRun not logging correctly to testing.T * Fiddling with sqlite3 temp file closing * Re-enable tests
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package libsq_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/neilotoole/sq/testh/sakila"
|
|
|
|
"github.com/neilotoole/sq/drivers/mysql"
|
|
|
|
_ "github.com/mattn/go-sqlite3"
|
|
)
|
|
|
|
//nolint:exhaustive
|
|
func TestQuery_unique(t *testing.T) {
|
|
testCases := []queryTestCase{
|
|
{
|
|
name: "unique/single-col",
|
|
in: `@sakila | .actor | .first_name | unique`,
|
|
wantSQL: `SELECT DISTINCT "first_name" FROM "actor"`,
|
|
override: driverMap{mysql.Type: "SELECT DISTINCT `first_name` FROM `actor`"},
|
|
wantRecCount: 128,
|
|
},
|
|
{
|
|
name: "unique/no-col",
|
|
in: `@sakila | .actor | unique`,
|
|
wantSQL: `SELECT DISTINCT * FROM "actor"`,
|
|
override: driverMap{mysql.Type: "SELECT DISTINCT * FROM `actor`"},
|
|
wantRecCount: sakila.TblActorCount,
|
|
},
|
|
{
|
|
name: "unique/no-col",
|
|
in: `@sakila | .actor | unique`,
|
|
wantSQL: `SELECT DISTINCT * FROM "actor"`,
|
|
override: driverMap{mysql.Type: "SELECT DISTINCT * FROM `actor`"},
|
|
wantRecCount: sakila.TblActorCount,
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
tc := tc
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
execQueryTestCase(t, tc)
|
|
})
|
|
}
|
|
}
|