Μετάβαση στο περιεχόμενο

assertSafeTable

Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.

assertSafeTable(table, purpose, example): string

Defined in: packages/pipeline/src/helpers/postgres-table.ts:25

Refuses a table name that is not safe to interpolate into SQL text.

A table name cannot be a query parameter, so a Postgres store writes it into the statement. Only table or schema.table made of unquoted identifiers (letters, digits and _, not starting with a digit) passes.

string

Table name from the store options, optionally schema-qualified.

string

What the table holds, for the error message (e.g. 'audit').

string

A valid table name for the error message (e.g. 'audit_log').

string

table, unchanged.

Error when table is not a safe identifier.

assertSafeTable('audit.audit_log', 'audit', 'audit_log'); // 'audit.audit_log'
assertSafeTable('x; DROP TABLE y', 'audit', 'audit_log'); // throws