npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vibeorm/sql

v5.3.0

Published

Dialect-aware SQL layer for VibeORM v2 — SQL AST, renderers and capability tables for postgres, sqlite and mysql

Readme

@vibeorm/sql

Part of VibeORM — a type-safe TypeScript ORM for Bun and Node. Prisma-schema or TypeScript-DSL input, a canonical schema IR, a generated client, and a dialect-aware SQL layer over PostgreSQL, PGlite, SQLite and MySQL.

The dialect-aware SQL layer. Every decision about SQL text — quoting, placeholders, per-dialect strategy switches, value encoding — lives in this package, so the runtime and migrate build a dialect-neutral AST and never concatenate SQL themselves.

bun add @vibeorm/sql

Stable. 2.0.0, published under the latest dist-tag. The v1 line stays installable as vibeorm@1.

Most users never install this directly — it ships as a dependency of vibeorm. Reach for it when you are building tooling on the IR or SQL layer.

What it exports

  • SQL AST: SqlStatement (SelectStatement, InsertStatement, UpdateStatement, DeleteStatement) and SqlExpr, plus the supporting node types ColRef, TableRef, SelectExpr, OrderTerm, AggRef, AggSelect, LateralJoin, InnerJoin, OnConflictClause, SetOperation, ListSetOperation, RowNumberProjection. Guards: isSetOperation, isListSetOperation, isSqlDefaultCell, and the SQL_DEFAULT_CELL marker.
  • Dialects: postgresDialect, sqliteDialect, mysqlDialect, the SqlDialect type, and the registry SQL_DIALECTS / getSqlDialect. A dialect carries quoteIdent plus the strategy switches: = ANY versus IN expansion, ILIKE versus LOWER(...) LIKE LOWER(...), the upsert form, ESCAPE clause presence, RETURNING availability.
  • Capability tables: DIALECT_CAPABILITIES, POSTGRES_CAPABILITIES, SQLITE_CAPABILITIES, MYSQL_CAPABILITIES — frozen objects consumed by the runtime, migrate, the generator and the E2E harness. A feature a dialect cannot express throws VIBE_UNSUPPORTED_CAPABILITY rather than degrading.
  • Codec tables: DIALECT_CODECS, POSTGRES_CODECS, SQLITE_CODECS, MYSQL_CODECS, decodeIsNoop, and the CodecTable / ScalarCodec / WireFidelity types. All per-dialect value encode and decode lives here, in one place, instead of scattered through query builders.
  • Rendering: renderStatement({ dialect, statement }) returns RenderedQuery ({ text, values, returning }); renderExpr and renderFragment render sub-parts against a shared ParamCollector. Placeholders always come from ParamCollector, never from hand-written $1 or ?.
  • LIKE helpers: escapeLikePattern, escapeGlobPattern, containsPattern, startsWithPattern, endsWithPattern, strictMatchPattern.

Rendering an AST

import { postgresDialect, renderStatement, sqliteDialect } from "@vibeorm/sql";
import type { SqlStatement } from "@vibeorm/sql";

const statement: SqlStatement = {
  kind: "select",
  table: { name: "User" },
  columns: [{ name: "id" }, { name: "email" }],
  where: { kind: "cmp", op: "eq", column: { name: "id" }, value: 1 },
};

renderStatement({ dialect: postgresDialect, statement });
// { text: `SELECT "id", "email" FROM "User" WHERE "id" = $1`, values: [1], ... }

renderStatement({ dialect: sqliteDialect, statement });
// { text: `SELECT "id", "email" FROM "User" WHERE "id" = ?`, values: [1], ... }

The returning field reports "native" when RETURNING was rendered, "omitted" when it was requested but the dialect lacks it (the caller re-selects), and "none" when it was not requested.

Reviewable SQL

Every statement shape this package can emit is pinned to its exact SQL text and parameters, per dialect, in sql-catalog.md. The file is generated from test-asserted cases (tests/catalog/cases.ts), so it cannot drift from the renderers.

Adding or changing a rendering means adding or updating a catalog case in the same change; bun run catalog:check enforces that in CI. Reviewing the catalog diff is how wrong quoting, bad placeholder order or dialect drift becomes visible without running a database.

Links