Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(oracle): reordered check constraint for unsigned numeric type (#1…
…6074) Co-authored-by: Rik Smale <13023439+WikiRik@users.noreply.github.com>
- Loading branch information
Showing
2 changed files
with
51 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
'use strict'; | ||
|
||
const Support = require('../../support'), | ||
DataTypes = require('sequelize/lib/data-types'), | ||
expectsql = Support.expectsql, | ||
current = Support.sequelize, | ||
sql = current.dialect.queryGenerator; | ||
|
||
if (current.dialect.name === 'oracle') { | ||
describe('createTable', () => { | ||
const FooUser = current.define('user', { | ||
intCol: { | ||
type: DataTypes.INTEGER.UNSIGNED, | ||
allowNull: false, | ||
defaultValue: 0 | ||
} | ||
}, | ||
{ | ||
schema: 'foo', | ||
timestamps: false | ||
}); | ||
|
||
describe('[Oracle Specific] QueryGenerator', () => { | ||
it('checks for values >=0', () => { | ||
expectsql(sql.createTableQuery(FooUser.getTableName(), sql.attributesToSQL(FooUser.rawAttributes), { }), { | ||
default: 'BEGIN EXECUTE IMMEDIATE \'CREATE TABLE "foo"."users" ("id" NUMBER(*,0) GENERATED BY DEFAULT ON NULL AS IDENTITY, "intCol" INTEGER DEFAULT 0 NOT NULL check("intCol" >= 0),PRIMARY KEY ("id"))\'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -955 THEN RAISE; END IF; END;' }); | ||
}); | ||
}); | ||
}); | ||
} |