diff --git a/drizzle-orm/src/sql/sql.ts b/drizzle-orm/src/sql/sql.ts index 03aea7287..44f30ae4f 100644 --- a/drizzle-orm/src/sql/sql.ts +++ b/drizzle-orm/src/sql/sql.ts @@ -610,6 +610,8 @@ export function fillPlaceholders(params: unknown[], values: Record; +const IsDrizzleView = Symbol.for('drizzle:IsDrizzleView'); + export abstract class View< TName extends string = string, TExisting extends boolean = boolean, @@ -636,6 +638,9 @@ export abstract class View< isAlias: boolean; }; + /** @internal */ + [IsDrizzleView] = true; + declare readonly $inferSelect: InferSelectViewModel, TExisting, TSelection>>; constructor( @@ -662,6 +667,10 @@ export abstract class View< } } +export function isView(view: unknown): view is View { + return typeof view === 'object' && view !== null && IsDrizzleView in view; +} + export type InferSelectViewModel = Equal extends true ? { [x: string]: unknown } : SelectResult<