Field
Represents a column reference, optionally schema/table-qualified and aliased. Select builds
Field instances internally for every string column you pass; use the constructor directly only
when you need to attach a dataType/isArray hint (typically for use with strict comparisons).
Constructor
Field(expression: string, dataType?: DataType, isArray?: boolean): Field
Field(args: { expression: string; dataType?: DataType; isArray?: boolean }): Field
new Field(...): Field
Dual-callable. expression must match [[schema.]table.]field[ [as] alias] — anything else
throws a TypeError ("does not match table column format"). A bare * is allowed and never gets
an alias, even if one is given.
import { Field, DataType } from '@sqb/builder';
Field('t.field1 f1', DataType.VARCHAR, false);
Field({ expression: 't.field1 f1', dataType: DataType.VARCHAR });
Properties
| Key | Type | Readonly | Description |
|---|---|---|---|
_type | SerializationType.FIELD_NAME | Yes | Discriminates this node during serialization. |
_field | string | No | The column name (or *). |
_table | string | undefined | No | Table qualifier, if present in the expression. |
_schema | string | undefined | No | Schema qualifier, if present in the expression. |
_alias | string | undefined | No | Alias, if present in the expression (never set for *). |
_dataType | DataType | undefined | No | Optional data type hint. |
_isArray | boolean | undefined | No | Optional array-field hint. |
Methods
Field has no chainable methods of its own — it exposes only its serialization logic. Reserved
words in _field/_alias are escaped (double-quoted) automatically when serialized without a
table/schema qualifier.
import { Select } from '@sqb/builder';
Select('with').from('customers').generate().sql;
// select "with" from customers
Select('schema1.table1.field1 f1').from('customers').generate().sql;
// select schema1.table1.field1 as f1 from customers