Skip to content

UNSIGNED is not supported in postgres dialect #1157

Closed

Description

@luiscubal

This is a test to reproduce the issue:

var Sequelize = require('sequelize');
var sequelize = new Sequelize('dbname', 'username', 'password', {
    'host': 'localhost',
    'port': 5432,
    'dialect': 'postgres'
});

var test = sequelize.define('test', {
    'value' : Sequelize.INTEGER.UNSIGNED
}, {});

sequelize.sync({force: true}).done(function(err) {
    if (err) console.log('Got error', err);
});

Expected: Empty output
Got:

`Got error [ { [error: syntax error at or near "UNSIGNED"]
    name: 'error',
    length: 90,
    severity: 'ERROR',
    code: '42601',
    detail: undefined,
    hint: undefined,
    position: '53',
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    file: 'scan.l',
    line: '1001',
    routine: 'scanner_yyerror' } ]

It seems that Postgres has no unsigned types at all (source). Perhaps it could be implemented by adding 1 bit to the size and adding a constraint?

Activity

  1. self-assigned this
    on May 17, 2014
  2. DNizovtsev commented on Feb 24, 2015

    @DNizovtsev

    the issue still not fixed

  3. mickhansen commented on Feb 25, 2015

    @mickhansen
    Contributor

    @DNizovtsev Hence it not being closed.
    Although with the new data types it could likely easily be fixed by removing the UNSIGNED keyword when using postgres - However i'm not sure i like it failing silently.

  4. BridgeAR commented on May 11, 2015

    @BridgeAR
    Contributor

    Wrong types won't be inserted any more. Instead unsigned/similar will be truncated.
    I'll open a new PR soon to add warnings if data types are used in a way that is not supported in the specific dialect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions