pg-mem icon indicating copy to clipboard operation
pg-mem copied to clipboard

Support: The query you ran generated an AST which parts have not been read by the query planner.

Open nikhilro opened this issue 4 years ago • 1 comments

Hey, the third attempt at trying to make this work failed too

Error:

     Error: 🔨 Not supported 🔨 : The query you ran generated an AST which parts have not been read by the query planner. This means that those parts could be ignored:

    ⇨ .where.left.args[0].table.name ("users")

👉 pg-mem is work-in-progress, and it would seem that you've hit one of its limits.

*️⃣ Failed SQL statement: update sp.users
      set team_id='ce78456f-b36e-4b54-9edb-c1f204c588e6', role='member'
      where split_part(sp.users.email,'@',2) = 'company.com';

This time I defined the function split_part using

    this.memoryDb.public.registerFunction({
      name: "split_part",
      args: [DataType.text, DataType.text, DataType.integer],
      returns: DataType.text,
      implementation: (source: string, separator: string, i: number) =>
        source.split(separator)[i - 1],
    });
Stacktrace
      at DbSchema._execOne (node_modules/pg-mem/src/schema.ts:277:27)
      at /Users/nikhil/superpowered/sp-backend/node_modules/pg-mem/src/schema.ts:118:31
      at Object.pushContext (node_modules/pg-mem/src/utils.ts:386:16)
      at DbSchema.queries (node_modules/pg-mem/src/schema.ts:115:47)
      at queries.next (<anonymous>)
      at DbSchema.query (node_modules/pg-mem/src/schema.ts:84:20)
      at MemPg.query (node_modules/pg-mem/src/adapters.ts:113:76)
      at FakeDatabase.<anonymous> (src/db/db.fake.ts:49:24)
      at step (src/db/db.fake.ts:33:23)
      at Object.next (src/db/db.fake.ts:14:53)
      at /Users/nikhil/superpowered/sp-backend/src/db/db.fake.ts:8:71
      at new Promise (<anonymous>)
      at __awaiter (src/db/db.fake.ts:4:12)
      at FakeDatabase.query (src/db/db.fake.ts:79:16)
      at UserDao.<anonymous> (src/components/user/userDao.ts:16:26)
      at step (src/components/user/userDao.ts:33:23)
      at Object.next (src/components/user/userDao.ts:14:53)
      at /Users/nikhil/superpowered/sp-backend/src/components/user/userDao.ts:8:71
      at new Promise (<anonymous>)
      at __awaiter (src/components/user/userDao.ts:4:12)
      at UserDao.userOrNull (src/components/user/userDao.ts:51:16)
      at UserDao.<anonymous> (src/components/user/userDao.ts:91:17)
      at step (src/components/user/userDao.ts:33:23)
      at Object.next (src/components/user/userDao.ts:14:53)
      at /Users/nikhil/superpowered/sp-backend/src/components/user/userDao.ts:8:71
      at new Promise (<anonymous>)
      at __awaiter (src/components/user/userDao.ts:4:12)
      at UserDao.assignUsersToTeam (src/components/user/userDao.ts:127:16)
      at Context.<anonymous> (src/components/billing/test/billing.individual.success.test.ts:210:17)
      at step (src/components/billing/test/billing.individual.success.test.ts:33:23)
      at Object.next (src/components/billing/test/billing.individual.success.test.ts:14:53)

Works fine in pg ofc

nikhilro avatar Jun 14 '21 15:06 nikhilro

That's a bug.

Sorry for the delay, I dont have time to work on pg-mem these days :(

I'll fix when I can... otherwise, if anyone wants to fix it, the bug is here ... this line should take into account when ExprRef.table is set

oguimbal avatar Jul 12 '21 12:07 oguimbal