2024-10-17 14:12:21 +02:00
|
|
|
package postgres
|
|
|
|
|
|
2026-05-09 01:43:14 +00:00
|
|
|
import "github.com/Gleipnir-Technology/jet/internal/jet"
|
2024-10-17 14:12:21 +02:00
|
|
|
|
|
|
|
|
type values struct {
|
|
|
|
|
jet.Values
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// VALUES is a table value constructor that computes a set of one or more rows as a temporary constant table.
|
|
|
|
|
// Each row is defined by the WRAP constructor, which takes one or more expressions.
|
|
|
|
|
//
|
|
|
|
|
// Example usage:
|
|
|
|
|
//
|
|
|
|
|
// VALUES(
|
2024-11-01 12:34:46 +01:00
|
|
|
// WRAP(Int32(204), Real(1.21)),
|
|
|
|
|
// WRAP(Int32(207), Real(1.02)),
|
2024-10-17 14:12:21 +02:00
|
|
|
// )
|
|
|
|
|
func VALUES(rows ...RowExpression) values {
|
|
|
|
|
return values{Values: jet.Values(rows)}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AS assigns an alias to the temporary VALUES table, allowing it to be referenced
|
|
|
|
|
// within SQL FROM clauses, just like a regular table.
|
|
|
|
|
// By default, VALUES columns are named `column1`, `column2`, etc... Default column aliasing can be
|
|
|
|
|
// overwritten by passing new list of columns.
|
|
|
|
|
//
|
|
|
|
|
// Example usage:
|
|
|
|
|
//
|
|
|
|
|
// VALUES(...).AS("film_values", IntegerColumn("length"), TimestampColumn("update_date"))
|
|
|
|
|
func (v values) AS(alias string, columns ...Column) SelectTable {
|
|
|
|
|
return newSelectTable(v, alias, columns)
|
|
|
|
|
}
|