不要怂,就是干,撸起袖子干!

Commit 791990dd by Jan Aagaard Meier

Remove length declaration for int and bigint in postgres. Closes #1575

1 parent a014bd8d
...@@ -772,6 +772,10 @@ module.exports = (function() { ...@@ -772,6 +772,10 @@ module.exports = (function() {
dataType = dataType.replace(/NOT NULL/, '') dataType = dataType.replace(/NOT NULL/, '')
} }
if (Utils._.includes(dataType, 'INTEGER') || Utils._.includes(dataType, 'BIGINT')) {
dataType = dataType.replace(/(INTEGER|BIGINT)\s*\(\d+\)/, '$1') // Postgres does not allow length on INTEGER and BIGINT
}
if (dataType.lastIndexOf('BLOB') !== -1 || dataType.lastIndexOf('BINARY') !== -1) { if (dataType.lastIndexOf('BLOB') !== -1 || dataType.lastIndexOf('BINARY') !== -1) {
dataType = 'bytea' dataType = 'bytea'
} }
......
...@@ -115,6 +115,10 @@ if (dialect.match(/^postgres/)) { ...@@ -115,6 +115,10 @@ if (dialect.match(/^postgres/)) {
createTableQuery: [ createTableQuery: [
{ {
arguments: ['myTable', {int: 'INTEGER(1)', bigint: 'BIGINT(12)'}],
expectation: "CREATE TABLE IF NOT EXISTS \"myTable\" (\"int\" INTEGER, \"bigint\" BIGINT);",
},
{
arguments: ['myTable', {title: 'VARCHAR(255)', name: 'VARCHAR(255)'}], arguments: ['myTable', {title: 'VARCHAR(255)', name: 'VARCHAR(255)'}],
expectation: "CREATE TABLE IF NOT EXISTS \"myTable\" (\"title\" VARCHAR(255), \"name\" VARCHAR(255));", expectation: "CREATE TABLE IF NOT EXISTS \"myTable\" (\"title\" VARCHAR(255), \"name\" VARCHAR(255));",
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!