Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot insert a boolean value, only accepts "boolean strings" #439

Open
samson501 opened this issue Jan 20, 2025 · 0 comments
Open

Cannot insert a boolean value, only accepts "boolean strings" #439

samson501 opened this issue Jan 20, 2025 · 0 comments

Comments

@samson501
Copy link

Describe the bug

I cannot insert a boolean value true or false into the database using bind(), it only inserts properly when it's a "true" or "false" string.

 FAIL  __tests__/api/process-log-files/files-one.ts (8.711 s)
  ● /api/process-log-files › should process one file

    TypeError: rawStr.toLowerCase is not a function

    💥 This is a nasty error, which was unexpected by pg-mem. Also known "a bug" 😁 Please file an issue !

    *️⃣ Failed SQL statement: 
          INSERT INTO venues 
            (id, premium_enabled) 
          VALUES ($1, $2);

    👉 You can file an issue at https://github.com/oguimbal/pg-mem along with a way to reproduce this error (if you can), and  the stacktrace:

Full Stacktrace

      at value.setConversion.toBool.toBool (node_modules/pg-mem/src/datatypes/datatypes.ts:336:56)
      at Evaluator.val (node_modules/pg-mem/src/evaluator.ts:125:28)
      at Evaluator.get (node_modules/pg-mem/src/evaluator.ts:220:21)
      at Insert.performMutation (node_modules/pg-mem/src/execution/records-mutations/insert.ts:149:62)
      at Insert._doExecuteOnce (node_modules/pg-mem/src/execution/records-mutations/mutation-base.ts:60:29)
      at Insert.enumerate (node_modules/pg-mem/src/execution/records-mutations/mutation-base.ts:72:29)
          at enumerate.next (<anonymous>)
      at SelectExec.execute (node_modules/pg-mem/src/execution/select.ts:279:41)
      at node_modules/pg-mem/src/execution/statement-exec.ts:208:42
      at pushExecutionCtx (node_modules/pg-mem/src/utils.ts:404:16)
      at node_modules/pg-mem/src/execution/statement-exec.ts:196:54
      at StatementExec.niceErrors (node_modules/pg-mem/src/execution/statement-exec.ts:226:20)
      at StatementExec.executeStatement (node_modules/pg-mem/src/execution/statement-exec.ts:196:21)
      at Bound.doExecute (node_modules/pg-mem/src/schema/prepared.ts:248:25)
          at doExecute.next (<anonymous>)
      at Bound.executeAll (node_modules/pg-mem/src/schema/prepared.ts:226:30)
      at executeAll (__tests__/api/process-log-files/files-one.ts:18:49)
      at Object.queryHub (__tests__/api/process-log-files/files-one.ts:456:5)

To Reproduce

// Create table
db.prepare(
`create table venues
(
  id                      varchar(255) default NULL::character varying not null
      primary key,
  premium_enabled         boolean      default false
)`)

db.executeAll()

// Insert a boolean in table
db.prepare(
 `INSERT INTO venues 
    (id, premium_enabled) 
  VALUES ($1, $2)`

db.bind(
  ["SOMEID",  true]
)

db.executeAll()

pg-mem version

3.0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant