blob: 9b6190059eec8a9c137989ec35353ca08c100ced [file]
// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package entx
import (
"fmt"
"entgo.io/ent/dialect/sql"
)
// True returns a standard SQL TRUE predicate.
// This is primarily used for constructing custom ON clauses in JOINs (e.g., ON TRUE)
// or for "no-op" filters in complex modification blocks where a predicate is required.
func True() *sql.Predicate {
return sql.P(func(b *sql.Builder) {
b.WriteString("TRUE")
})
}
// CrossJoin adds a CROSS JOIN (implemented as JOIN ON TRUE) to the selector.
//
// Usage:
//
// entx.CrossJoin(s, t)
func CrossJoin(s *sql.Selector, t sql.TableView) *sql.Selector {
return s.Join(t).OnP(True())
}
// Lateral creates a table selector for use in LATERAL joins.
func Lateral(name string) *sql.SelectTable {
return sql.Table(fmt.Sprintf("LATERAL %s", name))
}