chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
require('dotenv/config');
|
||||
const Database = require('better-sqlite3');
|
||||
const { drizzle } = require('drizzle-orm/better-sqlite3');
|
||||
const { sqlite: schema } = require('./schema.cjs');
|
||||
import { describe, expect } from 'vitest';
|
||||
|
||||
describe('better-sqlite3', async (it) => {
|
||||
it('drizzle()', async () => {
|
||||
const db = drizzle();
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
});
|
||||
|
||||
it('drizzle(string)', async () => {
|
||||
const db = drizzle(':memory:');
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
});
|
||||
|
||||
it('drizzle(string, config)', async () => {
|
||||
const db = drizzle(':memory:', {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: string, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: ':memory:',
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: params, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: {
|
||||
source: ':memory:',
|
||||
},
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: {}, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: {},
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({...config})', async () => {
|
||||
const db = drizzle({
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle(client)', async () => {
|
||||
const client = new Database(':memory:');
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = new Database(':memory:');
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = new Database(':memory:');
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,97 @@
|
||||
require('dotenv/config');
|
||||
const { createClient } = require('@libsql/client');
|
||||
const { drizzle } = require('drizzle-orm/libsql');
|
||||
const { sqlite: schema } = require('./schema.cjs');
|
||||
import { describe, expect } from 'vitest';
|
||||
|
||||
describe('libsql', async (it) => {
|
||||
it('drizzle(string)', async () => {
|
||||
const db = drizzle(':memory:');
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
});
|
||||
|
||||
it('drizzle(string, config)', async () => {
|
||||
const db = drizzle(':memory:', {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: string, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: ':memory:',
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: params, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: {
|
||||
url: ':memory:',
|
||||
},
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle(client)', async () => {
|
||||
const client = createClient({
|
||||
url: ':memory:',
|
||||
});
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = createClient({
|
||||
url: ':memory:',
|
||||
});
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = createClient({
|
||||
url: ':memory:',
|
||||
});
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,153 @@
|
||||
require('dotenv/config');
|
||||
const { drizzle } = require('drizzle-orm/mysql2');
|
||||
const { createPool, createConnection, Connection } = require('mysql2');
|
||||
const { mysql: schema } = require('./schema.cjs');
|
||||
import { describe, expect } from 'vitest';
|
||||
|
||||
if (!process.env['MYSQL_CONNECTION_STRING']) {
|
||||
throw new Error('MYSQL_CONNECTION_STRING is not defined');
|
||||
}
|
||||
|
||||
describe('mysql2', async (it) => {
|
||||
it('drizzle(string)', async () => {
|
||||
const db = drizzle(
|
||||
process.env['MYSQL_CONNECTION_STRING'],
|
||||
);
|
||||
|
||||
await db.$client.execute(`SELECT 1`);
|
||||
|
||||
expect(db.$client.getConnection).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle(string, config)', async () => {
|
||||
const db = drizzle(
|
||||
process.env['MYSQL_CONNECTION_STRING'],
|
||||
{
|
||||
schema,
|
||||
mode: 'default',
|
||||
},
|
||||
);
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client.getConnection).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: string, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: process.env['MYSQL_CONNECTION_STRING'],
|
||||
schema,
|
||||
mode: 'default',
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client.getConnection).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: params, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: {
|
||||
uri: process.env['MYSQL_CONNECTION_STRING'],
|
||||
},
|
||||
schema,
|
||||
mode: 'default',
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client.getConnection).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle(client)', async () => {
|
||||
const client = createPool({
|
||||
uri: process.env['MYSQL_CONNECTION_STRING'],
|
||||
});
|
||||
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.$client.getConnection).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = createPool({
|
||||
uri: process.env['MYSQL_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
mode: 'default',
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client.getConnection).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = createPool({
|
||||
uri: process.env['MYSQL_CONNECTION_STRING'],
|
||||
});
|
||||
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
mode: 'default',
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client.getConnection).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mysql2:connection', async (it) => {
|
||||
it('drizzle(client)', async () => {
|
||||
const client = createConnection({
|
||||
uri: process.env['MYSQL_CONNECTION_STRING'],
|
||||
});
|
||||
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.$client.getConnection).toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = createConnection({
|
||||
uri: process.env['MYSQL_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
mode: 'default',
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client.getConnection).toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = createConnection({
|
||||
uri: process.env['MYSQL_CONNECTION_STRING'],
|
||||
});
|
||||
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
mode: 'default',
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client.getConnection).toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,92 @@
|
||||
require('dotenv/config');
|
||||
const { neon: pg } = require('@neondatabase/serverless');
|
||||
const { drizzle } = require('drizzle-orm/neon-http');
|
||||
const { pg: schema } = require('./schema.cjs');
|
||||
import { describe, expect } from 'vitest';
|
||||
|
||||
if (!process.env['NEON_CONNECTION_STRING']) {
|
||||
throw new Error('NEON_CONNECTION_STRING is not defined');
|
||||
}
|
||||
|
||||
describe('neon-http', async (it) => {
|
||||
it('drizzle(string)', async () => {
|
||||
const db = drizzle(
|
||||
process.env['NEON_CONNECTION_STRING'],
|
||||
);
|
||||
|
||||
await db.$client('SELECT 1;');
|
||||
});
|
||||
|
||||
it('drizzle(string, config)', async () => {
|
||||
const db = drizzle(
|
||||
process.env['NEON_CONNECTION_STRING'],
|
||||
{
|
||||
schema,
|
||||
},
|
||||
);
|
||||
|
||||
await db.$client('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: string, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: process.env['NEON_CONNECTION_STRING'],
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: params, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: {
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
},
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle(client)', async () => {
|
||||
const client = pg(
|
||||
process.env['NEON_CONNECTION_STRING'],
|
||||
);
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client('SELECT 1;');
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = pg(
|
||||
process.env['NEON_CONNECTION_STRING'],
|
||||
);
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = pg(
|
||||
process.env['NEON_CONNECTION_STRING'],
|
||||
);
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,211 @@
|
||||
require('dotenv/config');
|
||||
const { neonConfig, Pool, Client } = require('@neondatabase/serverless');
|
||||
const { drizzle } = require('drizzle-orm/neon-serverless');
|
||||
const { pg: schema } = require('./schema.cjs');
|
||||
const ws = require('ws');
|
||||
import { describe, expect } from 'vitest';
|
||||
|
||||
neonConfig.webSocketConstructor = ws;
|
||||
|
||||
if (!process.env['NEON_CONNECTION_STRING']) {
|
||||
throw new Error('NEON_CONNECTION_STRING is not defined');
|
||||
}
|
||||
|
||||
describe('neon-ws', async (it) => {
|
||||
it('drizzle(string)', async () => {
|
||||
const db = drizzle(
|
||||
process.env['NEON_CONNECTION_STRING'],
|
||||
);
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
});
|
||||
|
||||
it('drizzle(string, config)', async () => {
|
||||
const db = drizzle(
|
||||
process.env['NEON_CONNECTION_STRING'],
|
||||
{
|
||||
schema,
|
||||
},
|
||||
);
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
});
|
||||
|
||||
it('drizzle({connection: string, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: process.env['NEON_CONNECTION_STRING'],
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
});
|
||||
|
||||
it('drizzle({connection: params, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: {
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
},
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
});
|
||||
|
||||
it('drizzle(client)', async () => {
|
||||
const client = new Pool({
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = new Pool({
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = new Pool({
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
});
|
||||
});
|
||||
|
||||
describe('neon-ws:Client', async (it) => {
|
||||
it('drizzle(client)', async () => {
|
||||
const client = new Client({
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = new Client({
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = new Client({
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
});
|
||||
});
|
||||
|
||||
describe('neon-ws:PoolClient', async (it) => {
|
||||
it('drizzle(client)', async () => {
|
||||
const pool = new Pool({
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
});
|
||||
const client = await pool.connect();
|
||||
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
client.release();
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const pool = new Pool({
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
});
|
||||
const client = await pool.connect();
|
||||
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
client.release();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const pool = new Pool({
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
});
|
||||
const client = await pool.connect();
|
||||
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
client.release();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,201 @@
|
||||
require('dotenv/config');
|
||||
const { drizzle } = require('drizzle-orm/node-postgres');
|
||||
const pg = require('pg');
|
||||
const { pg: schema } = require('./schema.cjs');
|
||||
import { describe, expect } from 'vitest';
|
||||
|
||||
const Pool = pg.Pool;
|
||||
const Client = pg.Client;
|
||||
|
||||
if (!process.env['PG_CONNECTION_STRING']) {
|
||||
throw new Error('PG_CONNECTION_STRING is not defined');
|
||||
}
|
||||
|
||||
describe('node-pg', async (it) => {
|
||||
it('drizzle(string)', async () => {
|
||||
const db = drizzle(process.env['PG_CONNECTION_STRING']);
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
});
|
||||
|
||||
it('drizzle(string, config)', async () => {
|
||||
const db = drizzle(process.env['PG_CONNECTION_STRING'], {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: string, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: process.env['PG_CONNECTION_STRING'],
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: params, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: {
|
||||
connectionString: process.env['PG_CONNECTION_STRING'],
|
||||
},
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle(client)', async () => {
|
||||
const client = new Pool({
|
||||
connectionString: process.env['PG_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = new Pool({
|
||||
connectionString: process.env['PG_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = new Pool({
|
||||
connectionString: process.env['PG_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('node-pg:Client', async (it) => {
|
||||
it('drizzle(client)', async () => {
|
||||
const client = new Client({
|
||||
connectionString: process.env['PG_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client);
|
||||
|
||||
await client.connect();
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = new Client({
|
||||
connectionString: process.env['PG_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = new Client({
|
||||
connectionString: process.env['PG_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('node-pg:PoolClient', async (it) => {
|
||||
it('drizzle(client)', async () => {
|
||||
const pool = new Pool({
|
||||
connectionString: process.env['PG_CONNECTION_STRING'],
|
||||
});
|
||||
const client = await pool.connect();
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
client.release();
|
||||
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const pool = new Pool({
|
||||
connectionString: process.env['PG_CONNECTION_STRING'],
|
||||
});
|
||||
const client = await pool.connect();
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
client.release();
|
||||
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const pool = new Pool({
|
||||
connectionString: process.env['PG_CONNECTION_STRING'],
|
||||
});
|
||||
const client = await pool.connect();
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
client.release();
|
||||
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,88 @@
|
||||
require('dotenv/config');
|
||||
const { drizzle } = require('drizzle-orm/pglite');
|
||||
const { pg: schema } = require('./schema.cjs');
|
||||
const { PGlite: Database } = require('@electric-sql/pglite');
|
||||
import { describe, expect } from 'vitest';
|
||||
|
||||
describe('pglite', async (it) => {
|
||||
it('drizzle()', async () => {
|
||||
const db = drizzle();
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
await db.$client.close();
|
||||
});
|
||||
|
||||
it('drizzle(string)', async () => {
|
||||
const db = drizzle('memory://');
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
await db.$client.close();
|
||||
});
|
||||
|
||||
it('drizzle(string, config)', async () => {
|
||||
const db = drizzle('memory://', {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: {}, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: {},
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({...config})', async () => {
|
||||
const db = drizzle({
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle(client)', async () => {
|
||||
const client = new Database('memory://');
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
await db.$client.close();
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = new Database('memory://');
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = new Database('memory://');
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.exec('SELECT 1;');
|
||||
await db.$client.close();
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,101 @@
|
||||
require('dotenv/config');
|
||||
const { Client } = require('@planetscale/database');
|
||||
const { drizzle } = require('drizzle-orm/planetscale-serverless');
|
||||
const { mysql: schema } = require('./schema.cjs');
|
||||
import { describe, expect } from 'vitest';
|
||||
|
||||
if (!process.env['PLANETSCALE_CONNECTION_STRING']) {
|
||||
throw new Error('PLANETSCALE_CONNECTION_STRING is not defined');
|
||||
}
|
||||
|
||||
describe('planetscale', async (it) => {
|
||||
it('drizzle(string)', async () => {
|
||||
const db = drizzle(
|
||||
process.env['PLANETSCALE_CONNECTION_STRING'],
|
||||
);
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
});
|
||||
|
||||
it('drizzle(string, config)', async () => {
|
||||
const db = drizzle(
|
||||
process.env['PLANETSCALE_CONNECTION_STRING'],
|
||||
{
|
||||
schema,
|
||||
},
|
||||
);
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: string, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: process.env['PLANETSCALE_CONNECTION_STRING'],
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: params, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: {
|
||||
url: process.env['PLANETSCALE_CONNECTION_STRING'],
|
||||
},
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle(client)', async () => {
|
||||
const client = new Client({
|
||||
url: process.env['PLANETSCALE_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = new Client({
|
||||
url: process.env['PLANETSCALE_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = new Client({
|
||||
url: process.env['PLANETSCALE_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,81 @@
|
||||
require('dotenv/config');
|
||||
const { drizzle } = require('drizzle-orm/postgres-js');
|
||||
const pg = require('postgres');
|
||||
const { pg: schema } = require('./schema.cjs');
|
||||
import { describe, expect } from 'vitest';
|
||||
|
||||
if (!process.env['PG_CONNECTION_STRING']) {
|
||||
throw new Error('PG_CONNECTION_STRING is not defined');
|
||||
}
|
||||
|
||||
describe('postgres-js', async (it) => {
|
||||
it('drizzle(string)', async () => {
|
||||
const db = drizzle(process.env['PG_CONNECTION_STRING']);
|
||||
|
||||
await db.$client.unsafe('SELECT 1;');
|
||||
});
|
||||
|
||||
it('drizzle(string, config)', async () => {
|
||||
const db = drizzle(process.env['PG_CONNECTION_STRING'], {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.unsafe('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: string, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: process.env['PG_CONNECTION_STRING'],
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.unsafe('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: params, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: {
|
||||
url: process.env['PG_CONNECTION_STRING'],
|
||||
},
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.unsafe('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle(client)', async () => {
|
||||
const client = pg(process.env['PG_CONNECTION_STRING']);
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.unsafe('SELECT 1;');
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = pg(process.env['PG_CONNECTION_STRING']);
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.unsafe('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = pg(process.env['PG_CONNECTION_STRING']);
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.unsafe('SELECT 1;');
|
||||
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
const { int: mysqlInt, mysqlTable } = require('drizzle-orm/mysql-core');
|
||||
const { integer: pgInt, pgTable } = require('drizzle-orm/pg-core');
|
||||
const { integer: sqliteInt, sqliteTable } = require('drizzle-orm/sqlite-core');
|
||||
|
||||
module.exports.sqlite = {
|
||||
User: sqliteTable('test', {
|
||||
id: sqliteInt('id').primaryKey().notNull(),
|
||||
}),
|
||||
};
|
||||
|
||||
module.exports.pg = {
|
||||
User: pgTable('test', {
|
||||
id: pgInt('id').primaryKey().notNull(),
|
||||
}),
|
||||
};
|
||||
|
||||
module.exports.mysql = {
|
||||
User: mysqlTable('test', {
|
||||
id: mysqlInt('id').primaryKey().notNull(),
|
||||
}),
|
||||
};
|
||||
@@ -0,0 +1,88 @@
|
||||
require('dotenv/config');
|
||||
const { connect } = require('@tidbcloud/serverless');
|
||||
const { drizzle } = require('drizzle-orm/tidb-serverless');
|
||||
const { mysql: schema } = require('./schema.cjs');
|
||||
import { describe, expect } from 'vitest';
|
||||
|
||||
if (!process.env['TIDB_CONNECTION_STRING']) {
|
||||
throw new Error('TIDB_CONNECTION_STRING is not defined');
|
||||
}
|
||||
|
||||
describe('tidb', async (it) => {
|
||||
it('drizzle(string)', async () => {
|
||||
const db = drizzle(
|
||||
process.env['TIDB_CONNECTION_STRING'],
|
||||
);
|
||||
|
||||
await db.$client.execute(`SELECT 1`);
|
||||
});
|
||||
|
||||
it('drizzle(string, config)', async () => {
|
||||
const db = drizzle(
|
||||
process.env['TIDB_CONNECTION_STRING'],
|
||||
{
|
||||
schema,
|
||||
},
|
||||
);
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: string, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: process.env['TIDB_CONNECTION_STRING'],
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({connection: params, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
connection: {
|
||||
url: process.env['TIDB_CONNECTION_STRING'],
|
||||
},
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle(client)', async () => {
|
||||
const client = connect({
|
||||
url: process.env['TIDB_CONNECTION_STRING'],
|
||||
});
|
||||
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = connect({
|
||||
url: process.env['TIDB_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = connect({
|
||||
url: process.env['TIDB_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle({
|
||||
client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.execute('SELECT 1;');
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,229 @@
|
||||
require('dotenv/config');
|
||||
const vc = require('@vercel/postgres');
|
||||
const { drizzle } = require('drizzle-orm/vercel-postgres');
|
||||
const { pg: schema } = require('./schema.cjs');
|
||||
import { describe, expect } from 'vitest';
|
||||
const { sql, createClient, createPool } = vc;
|
||||
|
||||
const Pool = vc.VercelPool;
|
||||
const Client = vc.VercelClient;
|
||||
|
||||
if (!process.env['VERCEL_CONNECTION_STRING']) {
|
||||
throw new Error('VERCEL_CONNECTION_STRING is not defined');
|
||||
}
|
||||
|
||||
// Used for non-pooled connection
|
||||
if (!process.env['NEON_CONNECTION_STRING']) {
|
||||
throw new Error('NEON_CONNECTION_STRING is not defined');
|
||||
}
|
||||
process.env['POSTGRES_URL'] = process.env['VERCEL_CONNECTION_STRING'];
|
||||
|
||||
describe('vercel:sql', async (it) => {
|
||||
it('drizzle()', async () => {
|
||||
const db = drizzle();
|
||||
|
||||
await sql.connect();
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeTypeOf('function');
|
||||
});
|
||||
|
||||
it('drizzle(client)', async () => {
|
||||
const db = drizzle(sql);
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeTypeOf('function');
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const db = drizzle(sql, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeTypeOf('function');
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const db = drizzle({
|
||||
client: sql,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeTypeOf('function');
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({...config})', async () => {
|
||||
const db = drizzle({
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).toBeTypeOf('function');
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('vercel:Pool', async (it) => {
|
||||
it('drizzle(client)', async () => {
|
||||
const client = createPool({
|
||||
connectionString: process.env['VERCEL_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).not.toBeTypeOf('function');
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = createPool({
|
||||
connectionString: process.env['VERCEL_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).not.toBeTypeOf('function');
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = createPool({
|
||||
connectionString: process.env['VERCEL_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle({
|
||||
client: client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).not.toBeTypeOf('function');
|
||||
expect(db.$client).toBeInstanceOf(Pool);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('vercel:Client', async (it) => {
|
||||
it('drizzle(client)', async () => {
|
||||
const client = createClient({
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client);
|
||||
|
||||
await client.connect();
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).not.toBeTypeOf('function');
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const client = createClient({
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).not.toBeTypeOf('function');
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const client = createClient({
|
||||
connectionString: process.env['NEON_CONNECTION_STRING'],
|
||||
});
|
||||
const db = drizzle({
|
||||
client: client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
|
||||
expect(db.$client).not.toBeTypeOf('function');
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('vercel:PoolClient', async (it) => {
|
||||
it('drizzle(client)', async () => {
|
||||
const pool = createPool({
|
||||
connectionString: process.env['VERCEL_CONNECTION_STRING'],
|
||||
});
|
||||
const client = await pool.connect();
|
||||
|
||||
const db = drizzle(client);
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
client.release();
|
||||
|
||||
expect(db.$client).not.toBeTypeOf('function');
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
});
|
||||
|
||||
it('drizzle(client, config)', async () => {
|
||||
const pool = createPool({
|
||||
connectionString: process.env['VERCEL_CONNECTION_STRING'],
|
||||
});
|
||||
const client = await pool.connect();
|
||||
|
||||
const db = drizzle(client, {
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
client.release();
|
||||
|
||||
expect(db.$client).not.toBeTypeOf('function');
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
|
||||
it('drizzle({client, ...config})', async () => {
|
||||
const pool = createPool({
|
||||
connectionString: process.env['VERCEL_CONNECTION_STRING'],
|
||||
});
|
||||
const client = await pool.connect();
|
||||
|
||||
const db = drizzle({
|
||||
client: client,
|
||||
schema,
|
||||
});
|
||||
|
||||
await db.$client.query('SELECT 1;');
|
||||
client.release();
|
||||
|
||||
expect(db.$client).not.toBeTypeOf('function');
|
||||
expect(db.$client).not.toBeInstanceOf(Pool);
|
||||
expect(db.$client).toBeInstanceOf(Client);
|
||||
expect(db.query.User).not.toStrictEqual(undefined);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user