Declare base tables explicitly when aliasing raw ORM subqueries

In SQL builders that interpolate aliased table objects into raw fragments, never assume an alias object renders a valid FROM source. Some builders emit only the alias identifier, producing a query against a nonexistent relation. Declare the physical table together with its alias, compile the representative query, and assert the entire FROM clause. A mock that only checks later alias-qualified column references can pass while the database rejects the statement. This applies to raw or partially raw ORM queries; fully typed builder APIs may render aliases correctly.

Applies when: An ORM query mixes raw SQL fragments with aliased tables or correlated subqueries. Keywords: SQL ORM alias FROM relation generated query regression Drizzle Postgres