summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Ben Holmes <hey@bholmes.dev> 2024-03-26 13:43:04 -0400
committerGravatar GitHub <noreply@github.com> 2024-03-26 13:43:04 -0400
commitb5a80405b93a166f6f019209152b860ffe2f73ef (patch)
treed5bf0a6d842dfaa29b00dbfe3e9aacfe6beeb4b3
parent5f7e9c47e01116f6ec74b33770f480404680956a (diff)
downloadastro-b5a80405b93a166f6f019209152b860ffe2f73ef.tar.gz
astro-b5a80405b93a166f6f019209152b860ffe2f73ef.tar.zst
astro-b5a80405b93a166f6f019209152b860ffe2f73ef.zip
Fix `db.run()` type signature in production (#10566)
* deps: bump drizzle to latest patch * chore: changeset * feat(test): db.run output
-rw-r--r--.changeset/wild-nails-call.md5
-rw-r--r--packages/db/package.json2
-rw-r--r--packages/db/test/basics.test.js34
-rw-r--r--packages/db/test/fixtures/basics/src/pages/run.json.ts12
-rw-r--r--pnpm-lock.yaml11
5 files changed, 59 insertions, 5 deletions
diff --git a/.changeset/wild-nails-call.md b/.changeset/wild-nails-call.md
new file mode 100644
index 000000000..91ef0db9b
--- /dev/null
+++ b/.changeset/wild-nails-call.md
@@ -0,0 +1,5 @@
+---
+"@astrojs/db": patch
+---
+
+Fix `db.run()` type signature in production.
diff --git a/packages/db/package.json b/packages/db/package.json
index edb92c2be..dd0158182 100644
--- a/packages/db/package.json
+++ b/packages/db/package.json
@@ -66,7 +66,7 @@
"@libsql/client": "^0.5.5",
"async-listen": "^3.0.1",
"deep-diff": "^1.0.2",
- "drizzle-orm": "^0.30.2",
+ "drizzle-orm": "^0.30.4",
"github-slugger": "^2.0.0",
"kleur": "^4.1.5",
"nanoid": "^5.0.1",
diff --git a/packages/db/test/basics.test.js b/packages/db/test/basics.test.js
index 4fe9541fa..348e9066c 100644
--- a/packages/db/test/basics.test.js
+++ b/packages/db/test/basics.test.js
@@ -73,6 +73,23 @@ describe('astro:db', () => {
expect($('.session-id').text()).to.equal('12345');
expect($('.username').text()).to.equal('Mario');
});
+
+ it('Prints authors from raw sql call', async () => {
+ const json = await fixture.fetch('run.json').then((res) => res.json());
+ expect(json).to.deep.equal({
+ columns: ['_id', 'name', 'age2'],
+ columnTypes: ['INTEGER', 'TEXT', 'INTEGER'],
+ rows: [
+ [1, 'Ben', null],
+ [2, 'Nate', null],
+ [3, 'Erika', null],
+ [4, 'Bjorn', null],
+ [5, 'Sarah', null],
+ ],
+ rowsAffected: 0,
+ lastInsertRowid: null,
+ });
+ });
});
describe('development --remote', () => {
@@ -137,6 +154,23 @@ describe('astro:db', () => {
expect($('.session-id').text()).to.equal('12345');
expect($('.username').text()).to.equal('Mario');
});
+
+ it('Prints authors from raw sql call', async () => {
+ const json = await fixture.fetch('run.json').then((res) => res.json());
+ expect(json).to.deep.equal({
+ columns: ['_id', 'name', 'age2'],
+ columnTypes: ['INTEGER', 'TEXT', 'INTEGER'],
+ rows: [
+ [1, 'Ben', null],
+ [2, 'Nate', null],
+ [3, 'Erika', null],
+ [4, 'Bjorn', null],
+ [5, 'Sarah', null],
+ ],
+ rowsAffected: 0,
+ lastInsertRowid: null,
+ });
+ });
});
describe('build --remote', () => {
diff --git a/packages/db/test/fixtures/basics/src/pages/run.json.ts b/packages/db/test/fixtures/basics/src/pages/run.json.ts
new file mode 100644
index 000000000..82d5a6a7c
--- /dev/null
+++ b/packages/db/test/fixtures/basics/src/pages/run.json.ts
@@ -0,0 +1,12 @@
+/// <reference types="@astrojs/db" />
+import type { APIRoute } from 'astro';
+import { db, sql } from 'astro:db';
+
+export const GET: APIRoute = async () => {
+ const authors = await db.run(sql`SELECT * FROM Author`);
+ return new Response(JSON.stringify(authors), {
+ headers: {
+ 'content-type': 'application/json',
+ },
+ });
+};
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2ec92c131..c745d5e73 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -3842,8 +3842,8 @@ importers:
specifier: ^1.0.2
version: 1.0.2
drizzle-orm:
- specifier: ^0.30.2
- version: 0.30.2(@libsql/client@0.5.6)
+ specifier: ^0.30.4
+ version: 0.30.4(@libsql/client@0.5.6)
github-slugger:
specifier: ^2.0.0
version: 2.0.0
@@ -10133,8 +10133,8 @@ packages:
engines: {node: '>=10'}
dev: true
- /drizzle-orm@0.30.2(@libsql/client@0.5.6):
- resolution: {integrity: sha512-DNd3djg03o+WxZX3pGD8YD+qrWT8gbrbhaZ2W0PVb6yH4rtM/VTB92cTGvumcRh7SSd2KfV0NWYDB70BHIXQTg==}
+ /drizzle-orm@0.30.4(@libsql/client@0.5.6):
+ resolution: {integrity: sha512-kWoSMGbrOFkmkAweLTFtHJMpN+nwhx89q0mLELqT2aEU+1szNV8jrnBmJwZ0WGNp7J7yQn/ezEtxBI/qzTSElQ==}
peerDependencies:
'@aws-sdk/client-rds-data': '>=3'
'@cloudflare/workers-types': '>=3'
@@ -10148,6 +10148,7 @@ packages:
'@types/react': '>=18'
'@types/sql.js': '*'
'@vercel/postgres': '*'
+ '@xata.io/client': '*'
better-sqlite3: '>=7'
bun-types: '*'
expo-sqlite: '>=13.2.0'
@@ -10184,6 +10185,8 @@ packages:
optional: true
'@vercel/postgres':
optional: true
+ '@xata.io/client':
+ optional: true
better-sqlite3:
optional: true
bun-types: