type ApplyJoinOptionalityToMergedSchema<TExistingSchema, TNewSchema, TJoinType, TFromSourceName> = { [K in keyof TExistingSchema]: K extends TFromSourceName ? TJoinType extends "right" | "full" ? TExistingSchema[K] | undefined : TExistingSchema[K] : TExistingSchema[K] } & { [K in keyof TNewSchema]: TJoinType extends "left" | "full" ? TNewSchema[K] | undefined : TNewSchema[K] };
type ApplyJoinOptionalityToMergedSchema<TExistingSchema, TNewSchema, TJoinType, TFromSourceName> = { [K in keyof TExistingSchema]: K extends TFromSourceName ? TJoinType extends "right" | "full" ? TExistingSchema[K] | undefined : TExistingSchema[K] : TExistingSchema[K] } & { [K in keyof TNewSchema]: TJoinType extends "left" | "full" ? TNewSchema[K] | undefined : TNewSchema[K] };
Defined in: packages/db/src/query/builder/types.ts:622
ApplyJoinOptionalityToMergedSchema - Applies optionality rules when merging schemas
This type implements the SQL join optionality semantics:
For Existing Tables:
For New Tables:
Examples:
FROM users LEFT JOIN orders -- orders becomes optional
FROM users RIGHT JOIN orders -- users becomes optional
FROM users FULL JOIN orders -- both become optional
FROM users INNER JOIN orders -- both remain required
FROM users LEFT JOIN orders -- orders becomes optional
FROM users RIGHT JOIN orders -- users becomes optional
FROM users FULL JOIN orders -- both become optional
FROM users INNER JOIN orders -- both remain required
The intersection (&) ensures both existing and new schemas are merged into a single type while preserving all table references.
TExistingSchema extends ContextSchema
TNewSchema extends ContextSchema
TJoinType extends "inner" | "left" | "right" | "full" | "outer" | "cross"
TFromSourceName extends string
