kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
10.44k stars 267 forks source link

Construct standalone SQL Snippets #1054

Closed waji-io closed 3 months ago

waji-io commented 3 months ago

Hi,

I am trying to build small SQL snippets/fragments following one of the example from the docs but I seem to be missing something.

Example

const example = sql`concat(first_name, ' ', last_name)`;

console.log(JSON.stringify(example));

The resulting output is an empty object...

What I am trying to achieve is to dynamically generate a list of SQL fragments based on some input and apply them later to the actual query.

koskimas commented 3 months ago

It's not an empty object. It's an instance of a class with with private properties. Stringifying it will not show anything but an empty object. There's no way for you to see what's inside it.