PostgresGrammar
class PostgresGrammar extends Grammar (View source)
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
protected Connection | $connection | The connection used for escaping values. |
from Grammar |
protected string[] | $operators | All of the available clause operators. |
|
protected array | $bitwiseOperators | The grammar specific bitwise operators. |
|
protected string[] | $selectComponents | The components that make up a select clause. |
from Grammar |
static protected array | $customOperators | The Postgres grammar specific custom operators. |
|
static protected bool | $cascadeTruncate | Indicates if the cascade option should be used when truncating. |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Wrap a table in keyword identifiers.
Wrap a table that has an alias.
Wrap the given JSON selector.
Convert an array of column names into a delimited string.
Get the appropriate query parameter place-holder for a value.
Escapes a value for safe SQL embedding.
Split the given JSON selector into the field and the optional path and wrap them separately.
Wrap the given JSON path.
Wrap the given JSON path segment.
Format the where clause statements into one string.
Compile a "JSON contains" statement into SQL.
Compile a "JSON overlaps" statement into SQL.
Prepare the binding for a "JSON contains" statement.
Compile a "JSON contains key" statement into SQL.
Compile a "JSON length" statement into SQL.
Compile a "JSON value cast" statement into SQL.
Compile a single having clause.
Compile a having clause involving a bit operator.
Compile a having clause involving an expression.
Compile a row number clause.
Compile an insert and get ID statement into SQL.
Compile an insert statement using a subquery into SQL.
Compile an insert ignore statement using a subquery into SQL.
Compile an update statement without joins into SQL.
Compile an update statement with joins into SQL.
Compile an "upsert" statement into SQL.
Prepare the bindings for an update statement.
Compile a delete statement without joins into SQL.
Compile a delete statement with joins into SQL.
Prepare the bindings for a delete statement.
Compile a query to get the number of open connections for a database.
Compile the SQL statement to execute a savepoint rollback.
Wrap the given JSON selector for boolean values.
Wrap the given JSON boolean value.
Concatenate an array of segments, removing empties.
Remove the leading boolean from a statement.
Substitute the given bindings into the given raw SQL query.
Get the Postgres grammar specific operators.
Get an array of valid full text languages.
Compile a having clause involving a bitwise operator.
Prepares a JSON column being updated using the JSONB_SET function.
Prepare the bindings for an update statement.
Compile an update statement with joins or limit into SQL.
Compile a delete statement with joins or limit into SQL.
Wrap the attributes of the given JSON path.
Parse the given JSON path attribute for array keys.
Set any Postgres grammar specific custom operators.
Enable or disable the "cascade" option when compiling the truncate statement.
Details
string
wrapTable(Expression|string $table, string|null $prefix = null)
Wrap a table in keyword identifiers.
protected string
wrapAliasedTable(string $value, string|null $prefix = null)
Wrap a table that has an alias.
string
escape(string|float|int|bool|null $value, bool $binary = false)
Escapes a value for safe SQL embedding.
string|int|float
getValue(Expression|string|int|float $expression)
Transforms expressions to their scalar types.
string
getTablePrefix()
deprecated
deprecated Use DB::getTablePrefix()
Get the grammar's table prefix.
$this
setTablePrefix(string $prefix)
deprecated
deprecated Use DB::setTablePrefix()
Set the grammar's table prefix.
protected array
wrapJsonFieldAndPath(string $column)
Split the given JSON selector into the field and the optional path and wrap them separately.
protected array
compileComponents(Builder $query)
Compile the components necessary for a select clause.
protected string
compileAggregate(Builder $query, array $aggregate)
Compile an aggregated select clause.
protected string|null
compileColumns(Builder $query, array $columns)
Compile the "select *" portion of the query.
protected string
compileFrom(Builder $query, string $table)
Compile the "from" portion of the query.
protected string
compileJoins(Builder $query, array $joins)
Compile the "join" portions of the query.
string
compileJoinLateral(JoinLateralClause $join, string $expression)
Compile a "lateral join" clause.
protected array
compileWheresToArray(Builder $query)
Get an array of all the where clauses for the query.
protected string
concatenateWhereClauses(Builder $query, array $sql)
Format the where clause statements into one string.
protected string
whereBitwise(Builder $query, array $where)
Compile a bitwise operator where clause.
protected string
whereNotInRaw(Builder $query, array $where)
Compile a "where not in raw" clause.
For safety, whereIntegerInRaw ensures this method is only used with integer values.
protected string
whereInRaw(Builder $query, array $where)
Compile a "where in raw" clause.
For safety, whereIntegerInRaw ensures this method is only used with integer values.
protected string
whereBetweenColumns(Builder $query, array $where)
Compile a "between" where clause.
protected string
dateBasedWhere(string $type, Builder $query, array $where)
Compile a date based where clause.
protected string
whereColumn(Builder $query, array $where)
Compile a where clause comparing two columns.
protected string
whereSub(Builder $query, array $where)
Compile a where condition with a sub-select.
protected string
whereJsonBoolean(Builder $query, array $where)
Compile a "where JSON boolean" clause.
protected string
whereJsonContains(Builder $query, array $where)
Compile a "where JSON contains" clause.
protected string
compileJsonContains(string $column, string $value)
Compile a "JSON contains" statement into SQL.
protected string
whereJsonOverlaps(Builder $query, array $where)
Compile a "where JSON overlaps" clause.
protected string
compileJsonOverlaps(string $column, string $value)
Compile a "JSON overlaps" statement into SQL.
string
prepareBindingForJsonContains(mixed $binding)
Prepare the binding for a "JSON contains" statement.
protected string
whereJsonContainsKey(Builder $query, array $where)
Compile a "where JSON contains key" clause.
protected string
compileJsonContainsKey(string $column)
Compile a "JSON contains key" statement into SQL.
protected string
whereJsonLength(Builder $query, array $where)
Compile a "where JSON length" clause.
protected string
compileJsonLength(string $column, string $operator, string $value)
Compile a "JSON length" statement into SQL.
protected string
compileGroups(Builder $query, array $groups)
Compile the "group by" portions of the query.
protected string
compileHavingExpression(array $having)
Compile a having clause involving an expression.
protected string
compileOrders(Builder $query, array $orders)
Compile the "order by" portions of the query.
protected array
compileOrdersToArray(Builder $query, array $orders)
Compile the query orders to an array.
protected string
compileLimit(Builder $query, int $limit)
Compile the "limit" portions of the query.
protected string
compileOffset(Builder $query, int $offset)
Compile the "offset" portions of the query.
protected string
compileUnions(Builder $query)
Compile the "union" queries attached to the main query.
string
compileInsertOrIgnore(Builder $query, array $values)
Compile an insert ignore statement into SQL.
string
compileInsertGetId(Builder $query, array $values, string $sequence)
Compile an insert and get ID statement into SQL.
string
compileInsertUsing(Builder $query, array $columns, string $sql)
Compile an insert statement using a subquery into SQL.
string
compileInsertOrIgnoreUsing(Builder $query, array $columns, string $sql)
Compile an insert ignore statement using a subquery into SQL.
protected string
compileUpdateColumns(Builder $query, array $values)
Compile the columns for an update statement.
protected string
compileUpdateWithoutJoins(Builder $query, string $table, string $columns, string $where)
Compile an update statement without joins into SQL.
protected string
compileUpdateWithJoins(Builder $query, string $table, string $columns, string $where)
Compile an update statement with joins into SQL.
string
compileUpsert(Builder $query, array $values, array $uniqueBy, array $update)
Compile an "upsert" statement into SQL.
array
prepareBindingsForUpdate(array $bindings, array $values)
Prepare the bindings for an update statement.
protected string
compileDeleteWithoutJoins(Builder $query, string $table, string $where)
Compile a delete statement without joins into SQL.
protected string
compileDeleteWithJoins(Builder $query, string $table, string $where)
Compile a delete statement with joins into SQL.
string|null
compileThreadCount()
Compile a query to get the number of open connections for a database.
string
compileSavepointRollBack(string $name)
Compile the SQL statement to execute a savepoint rollback.
protected string
wrapJsonBooleanSelector(string $value)
Wrap the given JSON selector for boolean values.
string
substituteBindingsIntoRawSql(string $sql, array $bindings)
Substitute the given bindings into the given raw SQL query.
protected string
compileHavingBitwise(array $having)
Compile a having clause involving a bitwise operator.
protected string
compileJsonUpdateColumn(string $key, mixed $value)
Prepares a JSON column being updated using the JSONB_SET function.
protected string
compileUpdateWheres(Builder $query)
Compile the additional where clauses for updates with joins.
protected string
compileUpdateJoinWheres(Builder $query)
Compile the "join" clause where clauses for an update.
array
prepareBindingsForUpdateFrom(array $bindings, array $values)
Prepare the bindings for an update statement.
protected string
compileUpdateWithJoinsOrLimit(Builder $query, array $values)
Compile an update statement with joins or limit into SQL.
protected string
compileDeleteWithJoinsOrLimit(Builder $query)
Compile a delete statement with joins or limit into SQL.
protected array
parseJsonPathArrayKeys(string $attribute)
Parse the given JSON path attribute for array keys.