mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-02-14 00:42:10 +02:00
removed unnecessary count
This commit is contained in:
parent
0798b5ccbb
commit
c70ca97888
@ -206,9 +206,9 @@ func (app *BaseApp) IsCollectionNameUnique(name string, excludeIds ...string) bo
|
||||
query.AndWhere(dbx.NotIn("id", list.ToInterfaceSlice(uniqueExcludeIds)...))
|
||||
}
|
||||
|
||||
var exists bool
|
||||
var total int
|
||||
|
||||
return query.Row(&exists) == nil && !exists
|
||||
return query.Row(&total) == nil && total == 0
|
||||
}
|
||||
|
||||
// TruncateCollection deletes all records associated with the provided collection.
|
||||
|
@ -269,7 +269,7 @@ func (r *MigrationsRunner) initMigrationsTable() error {
|
||||
func (r *MigrationsRunner) isMigrationApplied(txApp App, file string) bool {
|
||||
var exists bool
|
||||
|
||||
err := txApp.DB().Select("count(*)").
|
||||
err := txApp.DB().Select("(1)").
|
||||
From(r.tableName).
|
||||
Where(dbx.HashExp{"file": file}).
|
||||
Limit(1).
|
||||
|
@ -202,7 +202,7 @@ func TestMigrationsRunnerRemoveMissingAppliedMigrations(t *testing.T) {
|
||||
func isMigrationApplied(app core.App, file string) bool {
|
||||
var exists bool
|
||||
|
||||
err := app.DB().Select("count(*)").
|
||||
err := app.DB().Select("(1)").
|
||||
From(core.DefaultMigrationsTable).
|
||||
Where(dbx.HashExp{"file": file}).
|
||||
Limit(1).
|
||||
@ -210,28 +210,3 @@ func isMigrationApplied(app core.App, file string) bool {
|
||||
|
||||
return err == nil && exists
|
||||
}
|
||||
|
||||
// // -------------------------------------------------------------------
|
||||
|
||||
// type testDB struct {
|
||||
// *dbx.DB
|
||||
// CalledQueries []string
|
||||
// }
|
||||
|
||||
// // NB! Don't forget to call `db.Close()` at the end of the test.
|
||||
// func createTestDB() (*testDB, error) {
|
||||
// sqlDB, err := sql.Open("sqlite", ":memory:")
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// db := testDB{DB: dbx.NewFromDB(sqlDB, "sqlite")}
|
||||
// db.QueryLogFunc = func(ctx context.Context, t time.Duration, sql string, rows *sql.Rows, err error) {
|
||||
// db.CalledQueries = append(db.CalledQueries, sql)
|
||||
// }
|
||||
// db.ExecLogFunc = func(ctx context.Context, t time.Duration, sql string, result sql.Result, err error) {
|
||||
// db.CalledQueries = append(db.CalledQueries, sql)
|
||||
// }
|
||||
|
||||
// return &db, nil
|
||||
// }
|
||||
|
Loading…
x
Reference in New Issue
Block a user