Skip to content

Commit 7c467d4

Browse files
authored
feat: infer bigint data type (#893)
1 parent 6547ffd commit 7c467d4

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ Design type | Sequelize data type
285285
`string` | `STRING`
286286
`boolean` | `BOOLEAN`
287287
`number` | `INTEGER`
288+
`bigint` | `BIGINT`
288289
`Date` | `DATE`
289290
`Buffer` | `BLOB`
290291

src/sequelize/data-type/data-type-service.ts

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export function inferDataType(designType: any): DataTypeAbstract | undefined {
1818
switch (designType) {
1919
case String:
2020
return DataTypes.STRING;
21+
case BigInt:
22+
return DataTypes.BIGINT;
2123
case Number:
2224
return DataTypes.INTEGER;
2325
case Boolean:

test/specs/table_column.spec.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {expect, use} from 'chai';
22
import * as chaiAsPromised from 'chai-as-promised';
33
import {ModelAttributes} from 'sequelize';
4-
import {Model, Table, Column, DataType} from "../../src";
4+
import {Model, Table, Column, DataType, AutoIncrement, PrimaryKey} from "../../src";
55
import {createSequelize} from "../utils/sequelize";
66
import {User} from "../models/User";
77
import {getOptions} from "../../src/model/shared/model-service";
@@ -197,6 +197,22 @@ describe('table_column', () => {
197197

198198
describe('column', () => {
199199

200+
it('should infer the correct data type for bigint', () => {
201+
@Table
202+
class BigIntModel extends Model {
203+
@PrimaryKey
204+
@AutoIncrement
205+
@Column
206+
id: bigint;
207+
}
208+
209+
sequelize.addModels([BigIntModel]);
210+
211+
const attributes = getAttributes(BigIntModel.prototype);
212+
213+
expect(attributes.id.type).to.equal(DataType.BIGINT);
214+
});
215+
200216
it('should create appropriate sql query', () => {
201217

202218
const seq = createSequelize(false);

0 commit comments

Comments
 (0)