question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"could not determine data type of parameter $1" in createQueryBuilder insert

See original GitHub issue

Issue type:

[ ] question [x ] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [x ] postgres [ ] sqlite [ ] sqljs [ ] react-native [ ] expo

TypeORM version:

[ ] latest [ ] @next [x ] 0.2.8 (or put your version here)

I am trying to create an insertQuery with sql function in Nestjs framework like this :

const result = await this.userRepository
      .createQueryBuilder()
      .insert()
      .into(User)
      .values({
        column_1: () => `nextval('table_id_seq')`,
        column_2: user.column_2,
        column_3: user.column_3,
        column_4: user.column_4,
        created_at: user.created_at,
      })
      .printSql()
      .execute();

The error :

error: { error: could not determine data type of parameter $1
    at Connection.parseE (C:\Users\trung\code\ims\exchange-nest\node_modules\pg\lib\connection.js:554:11)
    at Connection.parseMessage (C:\Users\trung\code\ims\exchange-nest\node_modules\pg\lib\connection.js:379:19)
    at Socket.<anonymous> (C:\Users\trung\code\ims\exchange-nest\node_modules\pg\lib\connection.js:119:22)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:601:20)
  name: 'error',
  length: 111,
  severity: 'ERROR',
  code: '42P18',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'postgres.c',
  line: '1350',
  routine: 'exec_parse_message' }

Is insertQuery not support param like column_1: () => nextval('table_id_seq'), like updateQuery in #465

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
1valdiscommented, Jul 28, 2020

@trunglh88 could you please reopen the issue? I just stumbled upon this and clearly that’s a bug. I want to use both printSql and values. In my values I simply pass an array of objects with simple values and not a single function.

3reactions
trunglh88commented, Nov 1, 2018

i remove .printSql() and query is execute success.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Postgres Sql `could not determine data type of parameter` by ...
The PostgreSQL driver tries to figure out the type of the parameters to tell those parameters directly to the PostgreSQL Server.
Read more >
getquill/quill - Gitter
@fwbrasil I am getting an error like "could not determine data type of parameter $1" based on a a query with a bunch...
Read more >
Using Query Builder - MikroORM
or EntityRepository to have access to createQueryBuilder() method. ... const qb = em.createQueryBuilder(Author); qb.update({ name: 'test 123', type: PublisherType ...
Read more >
TypeORM - Query Builder - Tutorialspoint
TypeORM - Query Builder, Query builder is used build complex SQL queries in an easy way. It is initialized from Connection method and...
Read more >
Select using Query Builder - typeorm - GitBook
When using the QueryBuilder , you need to provide unique parameters in your WHERE ... There are two types of results you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found