Skip to content

Commit a340a0f

Browse files
committed
feat: US-177 - Add drizzle-orm project-matrix fixture
1 parent 2f875b1 commit a340a0f

6 files changed

Lines changed: 3493 additions & 3653 deletions

File tree

docs/nodejs-compatibility.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ The [project-matrix test suite](https://github.com/rivet-dev/secure-exec/tree/ma
7575
| [ssh2](https://npmjs.com/package/ssh2) | Networking | SSH client/server, crypto, streams, events |
7676
| [ssh2-sftp-client](https://npmjs.com/package/ssh2-sftp-client) | Networking | SFTP client, file transfer APIs over SSH |
7777
| [pg](https://npmjs.com/package/pg) | Database | PostgreSQL client, Pool/Client classes, type parsers |
78+
| [drizzle-orm](https://npmjs.com/package/drizzle-orm) | Database | ORM schema definition, query building, ESM module graph |
7879
| [rivetkit](https://npmjs.com/package/rivetkit) | SDK | Local vendor package resolution |
7980
| crypto (builtin) | Crypto | `crypto.randomBytes`, `randomUUID`, `getRandomValues` |
8081
| fs-metadata-rename | Filesystem | `stat` metadata, `rename` semantics |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"entry": "src/index.js",
3+
"expectation": "pass"
4+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "project-matrix-drizzle-pass",
3+
"private": true,
4+
"type": "commonjs",
5+
"dependencies": {
6+
"drizzle-orm": "0.45.1"
7+
}
8+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"use strict";
2+
3+
const { pgTable, text, integer, serial, varchar, boolean } = require("drizzle-orm/pg-core");
4+
const { eq, and, sql } = require("drizzle-orm");
5+
6+
// Define a table schema without connecting to a database
7+
const users = pgTable("users", {
8+
id: serial("id").primaryKey(),
9+
name: text("name").notNull(),
10+
email: varchar("email", { length: 255 }).notNull(),
11+
age: integer("age"),
12+
active: boolean("active").default(true),
13+
});
14+
15+
// Inspect schema shape
16+
const tableName = users[Symbol.for("drizzle:Name")];
17+
const columnNames = Object.keys(users)
18+
.filter((k) => typeof k === "string" && !k.startsWith("_"))
19+
.sort();
20+
const idIsPrimary = users.id.primary;
21+
const nameNotNull = users.name.notNull;
22+
const emailLength = users.email.config ? users.email.config.length : null;
23+
24+
// Verify operators exist
25+
const eqExists = typeof eq === "function";
26+
const andExists = typeof and === "function";
27+
const sqlExists = typeof sql === "function";
28+
29+
// Verify sql template tag produces a fragment object
30+
const fragment = sql`${users.id} = 1`;
31+
const fragmentExists = fragment !== null && typeof fragment === "object";
32+
33+
const result = {
34+
tableName,
35+
columnNames,
36+
idIsPrimary,
37+
nameNotNull,
38+
emailLength,
39+
eqExists,
40+
andExists,
41+
sqlExists,
42+
fragmentExists,
43+
};
44+
45+
console.log(JSON.stringify(result));

0 commit comments

Comments
 (0)