mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
- Add log: boolean option to SQL.Options types - Implement ActiveRecord-style logging with Output.prettyln in Zig - Add timing information to track query duration - Enable logging for all three database adapters: - MySQL: Added to MySQLQuery.zig with timing in doRun/onResult/onWriteFail - PostgreSQL: Added to PostgresSQLQuery.zig with timing in doRun/onResult/onWriteFail - SQLite: Added to sqlite.ts using performance.now() and console.log - Zero-cost when disabled - only activates when log: true - Single-line output format: [**ADAPTER**] (duration) SQL [values] 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
17 lines
512 B
JavaScript
17 lines
512 B
JavaScript
// Simple test for SQL logging
|
|
console.log("Testing SQL logging...");
|
|
|
|
try {
|
|
const sql = new Bun.SQL(":memory:", { log: true });
|
|
console.log("SQLite connection created with logging enabled");
|
|
|
|
// Test queries
|
|
console.log("Running SQLite queries...");
|
|
await sql`CREATE TABLE test (id INTEGER, name TEXT)`;
|
|
await sql`INSERT INTO test VALUES (1, 'Alice')`;
|
|
const result = await sql`SELECT * FROM test`;
|
|
console.log("Query result:", result);
|
|
|
|
} catch (e) {
|
|
console.error("Error:", e.message);
|
|
} |