mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-04 23:56:30 +00:00
1e9119ace9
* update xorm.io * update module * update github.com/docker/cli * update github.com/docker/distribution * update github.com/docker/docker * update github.com/gin-gonic/gin * update github.com/golang-jwt/jwt/v4 * update github.com/golangci/golangci-lint * update github.com/gorilla/securecookie * update github.com/lib/pq * update github.com/mattn/go-sqlite3 * update github.com/moby/moby * update github.com/stretchr/testify * update github.com/urfave/cli/v2 * update github.com/xanzy/go-gitlab * finish * update module * clean
49 lines
1 KiB
Go
49 lines
1 KiB
Go
// Copyright 2022 The Xorm Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package builder
|
|
|
|
import (
|
|
"errors"
|
|
"io"
|
|
)
|
|
|
|
type condNotExists struct {
|
|
subQuery *Builder
|
|
}
|
|
|
|
var _ Cond = condNotExists{}
|
|
|
|
// NotExists returns Cond via condition
|
|
func NotExists(subQuery *Builder) Cond {
|
|
return &condNotExists{
|
|
subQuery: subQuery,
|
|
}
|
|
}
|
|
|
|
func (condNotExists condNotExists) WriteTo(w Writer) error {
|
|
if !condNotExists.IsValid() {
|
|
return errors.New("exists condition is nov valid")
|
|
}
|
|
if _, err := io.WriteString(w, "NOT EXISTS ("); err != nil {
|
|
return err
|
|
}
|
|
if err := condNotExists.subQuery.WriteTo(w); err != nil {
|
|
return err
|
|
}
|
|
_, err := io.WriteString(w, ")")
|
|
return err
|
|
}
|
|
|
|
func (condNotExists condNotExists) And(conds ...Cond) Cond {
|
|
return And(condNotExists, And(conds...))
|
|
}
|
|
|
|
func (condNotExists condNotExists) Or(conds ...Cond) Cond {
|
|
return Or(condNotExists, Or(conds...))
|
|
}
|
|
|
|
func (condNotExists condNotExists) IsValid() bool {
|
|
return condNotExists.subQuery != nil
|
|
}
|