final class PostgreSqlProvider
    extends Base
Public API: explicitly declared with @visibility public.

Faker Provider for generating syntactically valid PostgreSQL SQL statements.

This provider uses PostgreSQL's official Bison grammar (gram.y) to generate SQL that is syntactically valid. Note that generated SQL may not be semantically valid (tables/columns may not exist).

maxDepth selects shortest productions once the depth is reached; it is not a SQL length limit. The basic pipeline resolves lexical spaces without inserting comments. Optional clauses may be empty. Seed the supplied Faker generator to reproduce a run within the same package version.

Register the provider with Fakerdoctest
$faker = \Faker\Factory::create();
    $faker->addProvider(new \SqlFaker\PostgreSqlProvider($faker));
    $faker->parameterMarker(min: 2, max: 2) // => '$2'

Methods§

public function __construct(
    Generator $generator,
    string|null $version = null,
    ?GrammarCoverage $coverage = null,
)
Public API: explicitly declared with @visibility public.

Register SQL formatters on the supplied Faker generator.

Parameters

$generatorGeneratorFaker generator
$versionstring|nullPostgreSQL version tag. Null for default.
$coverage?GrammarCoverage
Choose a supported database versiondoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker, 'pg-17.2');
    $provider->integerLiteral(min: 42, max: 42) // => '42'
Reject an unsupported database versiondoctest
new \SqlFaker\PostgreSqlProvider(\Faker\Factory::create(), 'missing-version') // throws \RuntimeException: Unsupported
Calls 5
public function planner(): PlanBuilder
Public API: explicitly declared with @visibility public.

Prepares grammar analysis for constructing concrete generation plans.

Compile input before generating SQLdoctest
$provider = new \SqlFaker\PostgreSqlProvider(\Faker\Factory::create());
    $plan = (new \SqlFaker\Generation\Choice\BytePlanCompiler())->compile('', $provider->planner());
    $provider->generate($plan) === $provider->generate($plan) // => true
Test cases 1
Calls 1
public function generate<TRequiresNonEmpty of bool>(GenerationPlan<TRequiresNonEmpty> $plan): (TRequiresNonEmpty is true ? non-empty-string : string)
Public API: explicitly declared with @visibility public.

Generates through the same engine used by the convenience methods.

Parameters

$planGenerationPlan<TRequiresNonEmpty>

Returns

(TRequiresNonEmpty is true ? non-empty-string : string)

Throws

GenerationException When derivation fails
LexicalException When lexical realization fails
Generate a statement from deterministic choice bytesdoctest
$provider = new \SqlFaker\SqliteProvider(\Faker\Factory::create());
    $plan = \SqlFaker\Generation\Plan\GenerationPlan::all()->requiringNonEmpty()->withExpansionBudget(100);
    $provider->generate($plan) !== '' // => true
Test cases 1
Called from 49
Calls 1
public function sql(
    StatementType|null $type = null,
    int $maxDepth = PHP_INT_MAX,
): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a syntactically valid PostgreSQL SQL statement.

Parameters

$typeStatementType|nullStatement type (null for random)
$maxDepthint

Returns

non-empty-string Generated SQL statement
Select a statement type explicitlydoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->sql(\SqlFaker\PostgreSql\StatementType::Select, maxDepth: 0);
    preg_match('/\bSELECT\b/i', $sql) // => 1
Test cases 8
Calls 2
public function selectStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL SELECT statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate select statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->selectStatement(maxDepth: 0);
    preg_match('/\bSELECT\b/is', $sql) // => 1
Test cases 3
Calls 3
public function insertStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL INSERT statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate insert statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->insertStatement(maxDepth: 0);
    preg_match('/\bINSERT\b/is', $sql) // => 1
Test cases 1
Calls 3
public function updateStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL UPDATE statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate update statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->updateStatement(maxDepth: 0);
    preg_match('/\bUPDATE\b/is', $sql) // => 1
Test cases 2
Calls 3
public function deleteStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL DELETE statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate delete statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->deleteStatement(maxDepth: 0);
    preg_match('/\bDELETE\b/is', $sql) // => 1
Test cases 2
Calls 3
public function createTableStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL CREATE TABLE statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate create table statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->createTableStatement(maxDepth: 0);
    preg_match('/\bCREATE\b.*\bTABLE\b/is', $sql) // => 1
Test cases 1
Calls 3
public function createTableAsStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL CREATE TABLE AS statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate create table as statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->createTableAsStatement(maxDepth: 0);
    preg_match('/\bCREATE\b.*\bTABLE\b.*\bAS\b/is', $sql) // => 1
Test cases 1
Calls 3
public function createDomainStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL CREATE DOMAIN statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate create domain statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->createDomainStatement(maxDepth: 0);
    preg_match('/\bCREATE\b.*\bDOMAIN\b/is', $sql) // => 1
Test cases 1
Calls 3
public function alterTableStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL ALTER TABLE statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate alter table statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->alterTableStatement(maxDepth: 0);
    preg_match('/\bALTER\b.*\bTABLE\b/is', $sql) // => 1
Test cases 1
Calls 3
public function dropTableStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL DROP TABLE statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate drop table statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->dropTableStatement(maxDepth: 0);
    preg_match('/\bDROP\b.*\bTABLE\b/is', $sql) // => 1
Test cases 1
Calls 3
public function simpleStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate any PostgreSQL statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate simple statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->simpleStatement(maxDepth: 0);
    $sql !== '' // => true
Test cases 2
Calls 3
public function truncateStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL TRUNCATE statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate truncate statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->truncateStatement(maxDepth: 0);
    preg_match('/\bTRUNCATE\b/is', $sql) // => 1
Test cases 1
Calls 2
public function copyStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL COPY statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate copy statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->copyStatement(maxDepth: 0);
    preg_match('/\bCOPY\b/is', $sql) // => 1
Test cases 1
Calls 2
public function createIndexStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL CREATE INDEX statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate create index statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->createIndexStatement(maxDepth: 0);
    preg_match('/\bCREATE\b.*\bINDEX\b/is', $sql) // => 1
Test cases 1
Calls 2
public function transactionStatement(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL transaction statement (BEGIN/COMMIT/ROLLBACK).

Parameters

$maxDepthint

Returns

non-empty-string
Generate transaction statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->transactionStatement(maxDepth: 0);
    preg_match('/\b(?:ABORT|BEGIN|COMMIT|ROLLBACK|START|SAVEPOINT|RELEASE|PREPARE)\b/is', $sql) // => 1
Test cases 1
Calls 2
public function expr(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL expression.

Parameters

$maxDepthint

Returns

non-empty-string
Generate expr at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->expr(maxDepth: 0);
    $sql !== '' // => true
Test cases 1
Calls 2
public function simpleExpr(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a simple PostgreSQL expression.

Parameters

$maxDepthint

Returns

non-empty-string
Generate simple expr at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->simpleExpr(maxDepth: 0);
    $sql !== '' // => true
Test cases 1
Calls 2
public function literal(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL literal.

Parameters

$maxDepthint

Returns

non-empty-string
Generate literal at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->literal(maxDepth: 0);
    $sql !== '' // => true
Test cases 1
Calls 2
public function whereClause(int $maxDepth = PHP_INT_MAX): string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL WHERE clause.

Parameters

$maxDepthint

Returns

string
An optional clause can be empty at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $provider->whereClause(maxDepth: 0) // => ''
Test cases 1
Calls 2
public function sortClause(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL ORDER BY clause.

Parameters

$maxDepthint

Returns

non-empty-string
Generate sort clause at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->sortClause(maxDepth: 0);
    preg_match('/\bORDER\b.*\bBY\b/is', $sql) // => 1
Test cases 1
Calls 2
public function selectLimit(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL LIMIT clause.

Parameters

$maxDepthint

Returns

non-empty-string
Generate select limit at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->selectLimit(maxDepth: 0);
    preg_match('/\b(?:LIMIT|OFFSET|FETCH)\b/is', $sql) // => 1
Test cases 1
Calls 2
public function tableRef(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL table reference.

Parameters

$maxDepthint

Returns

non-empty-string
Generate table ref at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->tableRef(maxDepth: 0);
    $sql !== '' // => true
Test cases 1
Calls 2
public function joinedTable(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL joined table.

Parameters

$maxDepthint

Returns

non-empty-string
Generate joined table at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->joinedTable(maxDepth: 0);
    preg_match('/\bJOIN\b/is', $sql) // => 1
Test cases 1
Calls 2
public function qualifiedName(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL qualified name (table identifier).

Parameters

$maxDepthint

Returns

non-empty-string
Generate qualified name at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->qualifiedName(maxDepth: 0);
    $sql !== '' // => true
Test cases 1
Calls 2
public function subquery(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL subquery.

Parameters

$maxDepthint

Returns

non-empty-string
Generate subquery at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->subquery(maxDepth: 0);
    preg_match('/\(.*\bSELECT\b.*\)/is', $sql) // => 1
Test cases 1
Calls 2
public function withClause(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL WITH clause (CTE).

Parameters

$maxDepthint

Returns

non-empty-string
Generate with clause at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->withClause(maxDepth: 0);
    preg_match('/\bWITH\b.*\bAS\b/is', $sql) // => 1
Test cases 1
Calls 2
public function foreignKeyConstraint(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a named PostgreSQL foreign-key table constraint.

Parameters

$maxDepthint

Returns

non-empty-string
Generate foreign key constraint at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->foreignKeyConstraint(maxDepth: 0);
    preg_match('/\bCONSTRAINT\b.*\bFOREIGN\b.*\bREFERENCES\b/is', $sql) // => 1
Test cases 1
Calls 2
public function identifier(int $maxDepth = PHP_INT_MAX): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL identifier via grammar derivation.

Parameters

$maxDepthint

Returns

non-empty-string
Generate identifier at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->identifier(maxDepth: 0);
    $sql !== '' // => true
Test cases 2
Calls 2
public function quotedIdentifier(int $minLength = 1, int $maxLength = 63): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a double-quote-quoted PostgreSQL identifier.

Parameters

$minLengthint
$maxLengthint

Returns

non-empty-string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $token = $provider->quotedIdentifier(minLength: 4, maxLength: 4);
    preg_match('/^"[a-z_][a-z0-9_]{3}"$/', $token) // => 1
Test cases 3
Calls 2
public function stringLiteral(int $minLength = 1, int $maxLength = 255): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL string literal.

Parameters

$minLengthint
$maxLengthint

Returns

non-empty-string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $token = $provider->stringLiteral(minLength: 4, maxLength: 4);
    preg_match('/^\'[A-Za-z0-9_]{4}\'$/', $token) // => 1
Test cases 3
Calls 2
public function integerLiteral(int $min = 1, int $max = 2147483647): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL integer literal.

Parameters

$minint
$maxint

Returns

non-empty-string
Fix both bounds to obtain one valuedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $provider->integerLiteral(min: 42, max: 42) // => '42'
Test cases 3
Calls 2
public function decimalLiteral(int $precision = 10, int $scale = 2): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL decimal literal.

Parameters

$precisionint
$scaleint

Returns

non-empty-string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $token = $provider->decimalLiteral(precision: 5, scale: 2);
    preg_match('/^[0-9]{1,3}\.[0-9]{2}$/', $token) // => 1
Test cases 3
Calls 2
public function floatLiteral(
    int $precision = 10,
    int $scale = 2,
    int $minExponent = -307,
    int $maxExponent = 308,
): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL float literal with exponent (FCONST).

Parameters

$precisionint
$scaleint
$minExponentint
$maxExponentint

Returns

non-empty-string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $token = $provider->floatLiteral(precision: 5, scale: 2, minExponent: 3, maxExponent: 3);
    preg_match('/^[0-9]{1,3}\.[0-9]{2}e3$/', $token) // => 1
Test cases 3
Calls 2
public function hexLiteral(int $minLength = 1, int $maxLength = 16): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL hexadecimal literal (X'...' / XCONST).

Parameters

$minLengthint
$maxLengthint

Returns

non-empty-string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $token = $provider->hexLiteral(minLength: 4, maxLength: 4);
    preg_match('/^X\'[0-9a-f]{4}\'$/', $token) // => 1
Test cases 3
Calls 2
public function binaryLiteral(int $minLength = 1, int $maxLength = 64): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL bit string literal (B'...' / BCONST).

Parameters

$minLengthint
$maxLengthint

Returns

non-empty-string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $token = $provider->binaryLiteral(minLength: 4, maxLength: 4);
    preg_match('/^B\'[01]{4}\'$/', $token) // => 1
Test cases 3
Calls 2
public function dollarQuotedString(int $minLength = 1, int $maxLength = 255): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL dollar-quoted string ($$...$$).

Parameters

$minLengthint
$maxLengthint

Returns

non-empty-string
Constrain the generated token shapedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $token = $provider->dollarQuotedString(minLength: 4, maxLength: 4);
    preg_match('/^\$\$[A-Za-z0-9_]{4}\$\$$/', $token) // => 1
Test cases 3
Calls 2
public function parameterMarker(int $min = 1, int $max = 99): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a PostgreSQL parameter marker ($1, $2, etc.).

Parameters

$minint
$maxint

Returns

non-empty-string
Fix both bounds to obtain one valuedoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $provider->parameterMarker(min: 42, max: 42) // => '$42'
Test cases 3
Calls 2
public function insertFunctionUpsertStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate an upsert whose update expression calls a function.

Parameters

$maxDepthint

Returns

non-empty-string
Generate insert function upsert statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->insertFunctionUpsertStatement(maxDepth: 0);
    preg_match('/\bINSERT\b.*\bCONFLICT\b.*\bUPDATE\b.*\(/is', $sql) // => 1
Test cases 1
Calls 2
public function partialIndexUpsertStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate an upsert with a partial-index predicate.

Parameters

$maxDepthint

Returns

non-empty-string
Generate partial index upsert statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->partialIndexUpsertStatement(maxDepth: 0);
    preg_match('/\bCONFLICT\b.*\bWHERE\b.*\bUPDATE\b/is', $sql) // => 1
Test cases 1
Calls 2
public function domainDmlStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate an INSERT, UPDATE or DELETE for domain-oriented fuzzing.

Parameters

$maxDepthint

Returns

non-empty-string
Generate domain dml statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->domainDmlStatement(maxDepth: 0);
    preg_match('/\b(?:INSERT|UPDATE|DELETE)\b/is', $sql) // => 1
Test cases 1
Calls 2
public function fullTextSearchStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a query using the dialect full-text search syntax.

Parameters

$maxDepthint

Returns

non-empty-string
Generate full text search statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->fullTextSearchStatement(maxDepth: 0);
    preg_match('/\bSELECT\b.*@@/is', $sql) // => 1
Test cases 1
Calls 2
public function temporaryTableStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a temporary-table declaration.

Parameters

$maxDepthint

Returns

non-empty-string
Generate temporary table statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->temporaryTableStatement(maxDepth: 0);
    preg_match('/\bCREATE\b.*\bTEMP(?:ORARY)?\b.*\bTABLE\b/is', $sql) // => 1
Test cases 1
Calls 2
public function viewStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a view declaration.

Parameters

$maxDepthint

Returns

non-empty-string
Generate view statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->viewStatement(maxDepth: 0);
    preg_match('/\bCREATE\b.*\bVIEW\b.*\bAS\b/is', $sql) // => 1
Test cases 1
Calls 2
public function generatedColumnStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a table with a generated column.

Parameters

$maxDepthint

Returns

non-empty-string
Generate generated column statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->generatedColumnStatement(maxDepth: 0);
    preg_match('/\bGENERATED\b.*\bALWAYS\b.*\bAS\b/is', $sql) // => 1
Test cases 1
Calls 2
public function foreignKeyCascadeStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a foreign key with cascading update and delete actions.

Parameters

$maxDepthint

Returns

non-empty-string
Generate foreign key cascade statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->foreignKeyCascadeStatement(maxDepth: 0);
    preg_match('/\bREFERENCES\b.*\bCASCADE\b.*\bCASCADE\b/is', $sql) // => 1
Test cases 1
Calls 2
public function partitionOfStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a table partition declaration.

Parameters

$maxDepthint

Returns

non-empty-string
Generate partition of statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->partitionOfStatement(maxDepth: 0);
    preg_match('/\bPARTITION\b.*\bOF\b.*\bVALUES\b/is', $sql) // => 1
Test cases 1
Calls 2
public function tableSampleStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a query with TABLESAMPLE.

Parameters

$maxDepthint

Returns

non-empty-string
Generate table sample statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->tableSampleStatement(maxDepth: 0);
    preg_match('/\bTABLESAMPLE\b/is', $sql) // => 1
Test cases 1
Calls 2
public function doStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a DO statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate do statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->doStatement(maxDepth: 0);
    preg_match('/\bDO\b/is', $sql) // => 1
Test cases 1
Calls 2
public function mergeStatement(int $maxDepth = 40): non-empty-string
Public API: explicitly declared with @visibility public.

Generate a MERGE statement.

Parameters

$maxDepthint

Returns

non-empty-string
Generate merge statement at the shortest depthdoctest
$faker = \Faker\Factory::create();
    $provider = new \SqlFaker\PostgreSqlProvider($faker);
    $faker->seed(7);
    $sql = $provider->mergeStatement(maxDepth: 0);
    preg_match('/\bMERGE\b.*\bMATCHED\b/is', $sql) // => 1
Test cases 1
Calls 2

Private surface 1§

Implementation details, listed for orientation only.

private SqlGenerator $sql

Test cases 81§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 80
Other tests reaching this symbol 1