sqlx-ts icon indicating copy to clipboard operation
sqlx-ts copied to clipboard

sql query not being recognized in some scenario

Open kevinautin opened this issue 2 months ago • 0 comments

import { Effect, pipe } from 'effect';
import { sql } from 'sqlx-ts';

// recognized by sqlx-ts
const test1 = Effect.succeed(sql`
  SELECT
    name
  FROM
    user
`);

// NOT recognized
const test2 = Effect.succeed(sql`
  SELECT
    name
  FROM
    user
`).pipe(Effect.map((str) => str));

// recognized 
const test3 = pipe(
  Effect.succeed(sql`
    SELECT
      name
    FROM
      user
  `),
  Effect.map((str) => str),
);

When running the query checker using npx sqlx-ts --config=.sqlxrc.json ./src/ the sql query string inside of test1 is recognized, but not the one inside of test2. The only difference being the method call .pipe() (method on an Effect, from the Effect library). Interestingly enough, when the pipe method isn't used, but instead simply a pipe function is used around (for the same result in theory), sqlx-ts does recognize it properly.

What I mean by "not recognized", is that it won't detect it at all during the check (won't count it in the number of sql queries found, and won't notice if the content of the query is wrong).

I think you can reproduce the situation if you install Effect. There is probably a more general reason why it doesn't work (unrelated to Effect), but that's how the issue appeared to me so far.

kevinautin avatar Nov 03 '25 01:11 kevinautin