Skip to content

Invalid query in playground #818

@branislavjuhaas

Description

@branislavjuhaas

Describe the bug
/api/todos GET throws issue in postgres

 ERROR  [request error] [unhandled] [GET] http://localhost:3000/api/todos                                                                       5:04:25 PM


ℹ Error: Failed query: select "id", "title", "completed", "createdAt", "updatedAt" from "todos" "todos" where "todos"."completed" = $1 order by "todos"."createdAt" desc
params: false

 ⁃ at PglitePreparedQuery.queryWithCache (node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@_ab7351832084d4e7e84d05d5bcf8f4c1/node_modules/drizzle-orm/pg-core/session.js:41:15)
 ⁃ at async PglitePreparedQuery.execute (node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@_ab7351832084d4e7e84d05d5bcf8f4c1/node_modules/drizzle-orm/pglite/session.js:70:20)
 ⁃ at async Object.handler (playground/server/api/todos/index.get.ts:6:0)

    1 ┃  import { desc, eq } from 'drizzle-orm'
    2 ┃  import { db } from '@nuxthub/db'
    3 ┃
    4 ┃  export default eventHandler(async () => {
    5 ┃    // List todos for the current user
 ❯  6 ┃    return await db.query.todos.findMany({
    7 ┃      where: eq(schema.todos.completed, false),
    8 ┃      orderBy: [desc(schema.todos.createdAt)]
    9 ┃    })
   10 ┃  })
   11 ┃

 ⁃ (async file://node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:2011:19)
 ⁃ at async Object.callAsync (node_modules/.pnpm/[email protected]/node_modules/unctx/dist/index.mjs:72:16)
 ⁃ at async Object.callAsync (node_modules/.pnpm/[email protected]/node_modules/unctx/dist/index.mjs:72:16)
 ⁃ at async toNodeHandle (node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:2303:7)
 ⁃ at async b (node_modules/.pnpm/[email protected]/node_modules/node-mock-http/dist/index.mjs:1:6876)
 ⁃ at async C (node_modules/.pnpm/[email protected]/node_modules/node-mock-http/dist/index.mjs:1:7159)
 ⁃ at async $fetchRaw2 (node_modules/.pnpm/[email protected]/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs:274:26)

[CAUSE]
C {
  stack: 'invalid input syntax for type integer: "false"\n' +
  'at ye.Ve (./node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/chunk-3WWIVTCY.js:1:17616)\n' +
  'at ye.nt (./node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/chunk-3WWIVTCY.js:1:15003)\n' +
  'at ye.parse (./node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/chunk-3WWIVTCY.js:1:13755)\n' +
  'at ./node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/index.js:3:191801)\n' +
  'at wasm://wasm/021cbcb2:wasm-function[3707]:0x27cef1:undefined:undefined)\n' +
  'at wasm://wasm/021cbcb2:wasm-function[3717]:0x27d268:undefined:undefined)\n' +
  'at wasm://wasm/021cbcb2:wasm-function[9494]:0x509d72:undefined:undefined)\n' +
  'at wasm://wasm/021cbcb2:wasm-function[175]:0x598a3:undefined:undefined)\n' +
  'at invoke_v (./node_modules/.pnpm/@[email protected]/node_modules/@'... 115 more characters,
  message: 'invalid input syntax for type integer: "false"',
  length: 148,
  name: 'error',
  severity: 'ERROR',
  code: '22P02',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: "unnamed portal parameter $1 = '...'",
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'numutils.c',
  line: '619',
  routine: 'pg_strtoint32_safe',
  query: 'select "id", "title", "completed", "createdAt", "updatedAt" from
  "todos" "todos" where "todos"."completed" = $1 order by
  "todos"."createdAt" desc',
  params: [
    false,
  ],
  queryOptions: {
    rowMode: 'array',
    parsers: [Object],
  },
}
 ERROR  [request error] [unhandled] [GET] http://localhost:3000/api/todos                                                                       5:04:25 PM


ℹ Error: Failed query: select "id", "title", "completed", "createdAt", "updatedAt" from "todos" "todos" where "todos"."completed" = $1 order by "todos"."createdAt" desc
params: false

 ⁃ at PglitePreparedQuery.queryWithCache (node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@_ab7351832084d4e7e84d05d5bcf8f4c1/node_modules/drizzle-orm/pg-core/session.js:41:15)
 ⁃ at async PglitePreparedQuery.execute (node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@_ab7351832084d4e7e84d05d5bcf8f4c1/node_modules/drizzle-orm/pglite/session.js:70:20)
 ⁃ at async Object.handler (playground/server/api/todos/index.get.ts:6:0)

    1 ┃  import { desc, eq } from 'drizzle-orm'
    2 ┃  import { db } from '@nuxthub/db'
    3 ┃
    4 ┃  export default eventHandler(async () => {
    5 ┃    // List todos for the current user
 ❯  6 ┃    return await db.query.todos.findMany({
    7 ┃      where: eq(schema.todos.completed, false),
    8 ┃      orderBy: [desc(schema.todos.createdAt)]
    9 ┃    })
   10 ┃  })
   11 ┃

 ⁃ (async file://node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:2011:19)
 ⁃ at async Object.callAsync (node_modules/.pnpm/[email protected]/node_modules/unctx/dist/index.mjs:72:16)
 ⁃ at async Object.callAsync (node_modules/.pnpm/[email protected]/node_modules/unctx/dist/index.mjs:72:16)
 ⁃ at async toNodeHandle (node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:2303:7)
 ⁃ at async b (node_modules/.pnpm/[email protected]/node_modules/node-mock-http/dist/index.mjs:1:6876)
 ⁃ at async C (node_modules/.pnpm/[email protected]/node_modules/node-mock-http/dist/index.mjs:1:7159)
 ⁃ at async $fetchRaw2 (node_modules/.pnpm/[email protected]/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs:274:26)

[CAUSE]
C {
  stack: 'invalid input syntax for type integer: "false"\n' +
  'at ye.Ve (./node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/chunk-3WWIVTCY.js:1:17616)\n' +
  'at ye.nt (./node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/chunk-3WWIVTCY.js:1:15003)\n' +
  'at ye.parse (./node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/chunk-3WWIVTCY.js:1:13755)\n' +
  'at ./node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/index.js:3:191801)\n' +
  'at wasm://wasm/021cbcb2:wasm-function[3707]:0x27cef1:undefined:undefined)\n' +
  'at wasm://wasm/021cbcb2:wasm-function[3717]:0x27d268:undefined:undefined)\n' +
  'at wasm://wasm/021cbcb2:wasm-function[9494]:0x509d72:undefined:undefined)\n' +
  'at wasm://wasm/021cbcb2:wasm-function[175]:0x598a3:undefined:undefined)\n' +
  'at invoke_v (./node_modules/.pnpm/@[email protected]/node_modules/@'... 115 more characters,
  message: 'invalid input syntax for type integer: "false"',
  length: 148,
  name: 'error',
  severity: 'ERROR',
  code: '22P02',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: "unnamed portal parameter $1 = '...'",
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'numutils.c',
  line: '619',
  routine: 'pg_strtoint32_safe',
  query: 'select "id", "title", "completed", "createdAt", "updatedAt" from
  "todos" "todos" where "todos"."completed" = $1 order by
  "todos"."createdAt" desc',
  params: [
    false,
  ],
  queryOptions: {
    rowMode: 'array',
    parsers: [Object],
  },
}

This is caused by invalid query

Steps to reproduce

  1. Run playground
  2. Go to /database
  3. Booom, error's there

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions