fix: execute chained scoped selects once (DEV-3678) #174
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| validate: | |
| name: validate (${{ matrix.drizzle_label }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - drizzle_label: locked | |
| drizzle_install: "" | |
| - drizzle_label: rc | |
| drizzle_install: drizzle-orm@rc | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - run: pnpm install --frozen-lockfile | |
| - name: Use Drizzle ORM ${{ matrix.drizzle_install }} | |
| if: matrix.drizzle_install != '' | |
| run: pnpm add --save-dev ${{ matrix.drizzle_install }} --ignore-scripts | |
| - run: pnpm format:check | |
| - run: pnpm lint | |
| - run: pnpm typecheck | |
| - run: pnpm test | |
| - run: pnpm coverage | |
| - run: pnpm build | |
| - run: pnpm typecheck:dist | |
| - run: npm pack --dry-run | |
| - name: Smoke test Drizzle 1.0 rc compatibility | |
| if: matrix.drizzle_label == 'rc' | |
| run: | | |
| node --input-type=module <<'JS' | |
| import { eq } from "drizzle-orm"; | |
| import * as pg from "drizzle-orm/pg-core"; | |
| import { mysqlTable, varchar } from "drizzle-orm/mysql-core"; | |
| import { sqliteTable, text as sqliteText } from "drizzle-orm/sqlite-core"; | |
| import { containsColumnFilter, scopeByColumn } from "./dist/index.js"; | |
| const tables = [ | |
| pg.pgTable("pg_projects", { workspaceId: pg.text("workspace_id") }), | |
| mysqlTable("mysql_projects", { workspaceId: varchar("workspace_id", { length: 64 }) }), | |
| sqliteTable("sqlite_projects", { workspaceId: sqliteText("workspace_id") }), | |
| pg.snakeCase.table("snake_case_projects", { workspaceId: pg.text() }), | |
| ]; | |
| for (const table of tables) { | |
| scopeByColumn(table, table.workspaceId).where("workspace-1"); | |
| if (!containsColumnFilter(eq(table.workspaceId, "workspace-1"), "workspace_id")) { | |
| throw new Error(`Drizzle SQL chunks did not expose workspace_id for ${table.workspaceId.name}`); | |
| } | |
| } | |
| JS | |
| - name: Verify npm peer resolution with Drizzle 1.0 rc | |
| if: matrix.drizzle_label == 'rc' | |
| run: | | |
| tarball="$(npm pack --ignore-scripts --silent | tail -n 1)" | |
| app_dir="$(mktemp -d)" | |
| cd "$app_dir" | |
| npm init -y | |
| npm install "$GITHUB_WORKSPACE/$tarball" drizzle-orm@rc --ignore-scripts --no-audit --no-fund |