Skip to content

Commit

Permalink
Added support for UNSIGNED columns in MySQL. (Kononnable#179)
Browse files Browse the repository at this point in the history
Added support for UNSIGNED columns in MySQL.
  • Loading branch information
Kononnable authored Jul 19, 2019
2 parents df20dee + 71c4f0e commit ce8d37c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/drivers/MysqlDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export class MysqlDriver extends AbstractDriver {
resp.COLUMN_DEFAULT
);
colInfo.options.type = resp.DATA_TYPE as any;
colInfo.options.unsigned = resp.COLUMN_TYPE.endsWith(
" unsigned"
);
switch (resp.DATA_TYPE) {
case "int":
colInfo.tsType = "number";
Expand Down
3 changes: 2 additions & 1 deletion src/entity.mst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {BaseEntity,Column,Entity,Index,JoinColumn,JoinTable,ManyToMany,ManyToOne
primary:{{primary}},{{/primary}}{{/generated}}{{#unique}}
unique: true,{{/unique}}{{#length}}
length:{{.}},{{/length}}{{#width}}
width:{{.}},{{/width}}{{#default}}
width:{{.}},{{/width}}{{#unsigned}}
unsigned: true,{{/unsigned}}{{#default}}
default: {{.}},{{/default}}{{#precision}}
precision:{{.}},{{/precision}}{{#scale}}
scale:{{.}},{{/scale}}{{#enum}}
Expand Down
5 changes: 4 additions & 1 deletion test/integration/entityTypes/mysql/entity/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ export class Post {
@Column("int")
int: number;

@Column("int", { unsigned: true })
uint: number;

@Column("tinyint")
tinyint: number;

@Column("tinyint",{width:1})
@Column("tinyint", { width: 1 })
boolean: boolean;

@Column("smallint")
Expand Down

0 comments on commit ce8d37c

Please sign in to comment.