db-migrate / node-db-migrate

Database migration framework for node
Other
2.32k stars 361 forks source link

If trying to set length of int: Error in query: ERROR: syntax error at or near "(" #809

Closed b1ek closed 1 year ago

b1ek commented 1 year ago

I'm submitting a...

Current behavior

[ERROR] error: syntax error at or near "("
    at Parser.parseErrorMessage (/usr/lib/node_modules/db-migrate-pg/node_modules/pg-protocol/dist/parser.js:287:98)
    at Parser.handlePacket (/usr/lib/node_modules/db-migrate-pg/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/usr/lib/node_modules/db-migrate-pg/node_modules/pg-protocol/dist/parser.js:39:38)
    at Socket.<anonymous> (/usr/lib/node_modules/db-migrate-pg/node_modules/pg-protocol/dist/index.js:11:42)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

Expected behavior

So that it would build the query correctly

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment

db-migrate version: 0.11.13
plugins with versions: db-migrate-pg 1.2.2

Additional information:
- Node version: 9.3.0
- Platform: Arch

The migration:
db.createTable(
  'user_defs',
  {
    id: {
      type: 'int',
      notNull: true,
      primaryKey: true,
      autoIncrement: true,
      length: 12
    },
    login: 'text',
    pass: 'text'
  }
);

Generated SQL query:
CREATE TABLE  "user_defs" ("id"  (12) SERIAL PRIMARY KEY NOT NULL, "login" TEXT  , "pass" TEXT  ) ;
                                ^^^ Error in query: ERROR: syntax error at or near "("
wzrdtales commented 1 year ago

this node version is no longer supported, please upgrade. also: an autoIncrement on postgres results in a serial type which does not support or need a length specification.

b1ek commented 1 year ago

this node version is no longer supported, please upgrade

shouldn't there be a warning or something?

wzrdtales commented 1 year ago

no that is not really our duty, we support officially only LTS, db-migrate will work with most older versions usually, though. However, you're literally using a node version from the stone age. Actually, your it department should have warned you that you're endangering the company by using outdated software with open security holes. but that is a different story.

b1ek commented 1 year ago

How is 19.3 stone age? That is just a little bit outdated.

I tested it on multiple node versions though (19.4, 18.13, 14.21.2), the query generates wrong on each one of them. I don't see how that issue is related to the node version.

If it works properly only on some specific node version, there definitely should be a note about it somewhere, or a runtime warning as it required me to create an issue to learn about.

wzrdtales commented 1 year ago

You wrote 9 not 19

Sent from Nine

--

Best

-- Tobias Gurtzick CEO WizardTales GmbH

Additional Contacts: @github | @.***

Website: https://www.wizardtales.com @.*** nmlpm: -- coming soon & open source --

Please tag your mails with "request", "issue" or "proposal", unless none of these fit or there already exists a thread.

-- Why should one reach for what one may be capable reaching, that's awfully boring and after all one still be ones yesterday being. --

Sitz der Gesellschaft: Ratingen Kokkolastr. 5 40882 Ratingen Germany

Registergericht: Amtsgericht Düsseldorf, HRB 84140 Geschäftsführer: Tobias Gurtzick


Von: blek! @.***> Gesendet: Donnerstag, 19. Januar 2023 07:08 An: db-migrate/node-db-migrate Cc: Tobias Gurtzick; State change Betreff: Re: [db-migrate/node-db-migrate] If trying to set length of int: Error in query: ERROR: syntax error at or near "(" (Issue #809)

How is 19.3 stone age? That is just a little bit outdated. I tested it on multiple node versions though (19.4, 18.13, 14.21.2), the query generates wrong on each one of them. I don't see how that issue is related to the node version. If it works properly only on some specific node version, there definitely should be a note about it somewhere, or a runtime warning as it required me to create an issue to learn about. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>