Skip to content

Commit b2965ca

Browse files
author
Tobin Brown
committed
infer bigint data type
1 parent ffe1c78 commit b2965ca

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

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/data-type-service.spec.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {expect} from 'chai';
2+
import {DataTypes} from 'sequelize';
3+
import { AutoIncrement, Column, Model, PrimaryKey, Table } from '../../src';
4+
import {createSequelize} from "../utils/sequelize";
5+
import {getAttributes} from '../../src/model/column/attribute-service';
6+
7+
describe('data type service', () => {
8+
describe('inferDataTypes', () => {
9+
it('correctly infers bigint data type', () => {
10+
11+
@Table
12+
class BigIntModel extends Model {
13+
@PrimaryKey
14+
@AutoIncrement
15+
@Column
16+
id: bigint;
17+
}
18+
19+
const sequelize = createSequelize();
20+
sequelize.addModels([BigIntModel]);
21+
22+
const attributes = getAttributes(BigIntModel.prototype);
23+
24+
expect(attributes.id.type).to.equal(DataTypes.BIGINT);
25+
});
26+
});
27+
});

0 commit comments

Comments
 (0)