added column types tests
This commit is contained in:
parent
d870654fc8
commit
52884da881
@ -75,12 +75,20 @@ export class MssqlDriver extends AbstractDriver {
|
||||
colInfo.ts_type = "number"
|
||||
colInfo.sql_type = "float"
|
||||
break;
|
||||
case "date":
|
||||
case "bigint":
|
||||
colInfo.ts_type = "number"
|
||||
colInfo.sql_type = "bigint"
|
||||
break;
|
||||
case "date":
|
||||
colInfo.ts_type = "Date"
|
||||
colInfo.sql_type = "date"
|
||||
break;
|
||||
case "time":
|
||||
colInfo.ts_type = "Date"
|
||||
colInfo.sql_type = "time"
|
||||
break;
|
||||
case "datetime":
|
||||
colInfo.ts_type = "number";
|
||||
colInfo.ts_type = "Date";
|
||||
colInfo.sql_type = "datetime"
|
||||
break;
|
||||
case "char":
|
||||
|
@ -12,9 +12,9 @@ import {Index,Entity, PrimaryColumn, Column, OneToOne, OneToMany, ManyToOne, Joi
|
||||
nullable:true,{{/is_nullable}}{{^is_nullable}}
|
||||
nullable:false,{{/is_nullable}}{{#char_max_lenght}}
|
||||
length:{{.}},{{/char_max_lenght}}{{#default}}
|
||||
default:"{{default}}",{{/default}}{{#numericPrecision}}
|
||||
precision:{{numericPrecision}},{{/numericPrecision}}{{#numericScale}}
|
||||
scale:{{numericScale}},{{/numericScale}}{{#isPrimary}}
|
||||
default:"{{.}}",{{/default}}{{#numericPrecision}}
|
||||
precision:{{.}},{{/numericPrecision}}{{#numericScale}}
|
||||
scale:{{.}},{{/numericScale}}{{#isPrimary}}
|
||||
primary:{{isPrimary}},{{/isPrimary}}
|
||||
})
|
||||
{{name}}:{{ts_type}};
|
||||
|
@ -6,9 +6,9 @@ export class ColumnInfo {
|
||||
name: string='';
|
||||
default: string|null=null;
|
||||
is_nullable: boolean=false;
|
||||
ts_type: 'number' | 'string' | 'boolean';
|
||||
ts_type: 'number' | 'string' | 'boolean' | 'Date';
|
||||
sql_type: "string" | "text" | "number" | "integer" | "int" | "smallint" | "bigint" |
|
||||
"float" | "double" | "decimal" | "date" | "time" | "datetime" | "boolean" | "json";
|
||||
"float" | "double" | "decimal" | "date" | "time" | "datetime" | "boolean" | "json" ;
|
||||
char_max_lenght: number|null=null;
|
||||
isPrimary:boolean=false;
|
||||
is_generated:boolean=false;
|
||||
|
@ -0,0 +1,72 @@
|
||||
import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn, Index } from "typeorm";
|
||||
|
||||
@Entity("EverythingEntity")
|
||||
export class EverythingEntity {
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
@Column("text")
|
||||
text: string;
|
||||
|
||||
@Column({ length: 32 })
|
||||
shortTextColumn: string;
|
||||
|
||||
@Column()
|
||||
numberColumn: number;
|
||||
|
||||
@Column("integer")
|
||||
integerColumn: number;
|
||||
|
||||
@Column("int")
|
||||
intColumn: number;
|
||||
|
||||
@Column("smallint")
|
||||
smallintColumn: number;
|
||||
|
||||
@Column("bigint")
|
||||
bigintColumn: number;
|
||||
|
||||
@Column("float")
|
||||
floatColumn: number;
|
||||
|
||||
@Column("double")
|
||||
doubleColumn: number;
|
||||
|
||||
@Column("decimal")
|
||||
decimalColumn: number;
|
||||
|
||||
@Column()
|
||||
date: Date;
|
||||
|
||||
@Column("date")
|
||||
dateColumn: Date;
|
||||
|
||||
@Column("time")
|
||||
timeColumn: Date;
|
||||
|
||||
@Column("boolean")
|
||||
isBooleanColumn: boolean;
|
||||
|
||||
@Column("boolean")
|
||||
isSecondBooleanColumn: boolean;
|
||||
|
||||
@Column("json")
|
||||
jsonColumn: any;
|
||||
|
||||
// @Column()
|
||||
// alsoJson: any;
|
||||
|
||||
// @Column("simple_array")
|
||||
// simpleArrayColumn: string[];
|
||||
|
||||
// @CreateDateColumn()
|
||||
// createdDate: Date;
|
||||
|
||||
// @UpdateDateColumn()
|
||||
// updatedDate: Date;
|
||||
|
||||
}
|
@ -172,6 +172,9 @@ export class EntityFileToJson {
|
||||
retVal.columns[retVal.columns.length - 1].columnName = trimmedLine.split(':')[0].trim();
|
||||
//TODO:Should check if null only column is nullable?
|
||||
retVal.columns[retVal.columns.length - 1].columnTypes = trimmedLine.split(':')[1].split(';')[0].trim().split('|').map(function (x) {
|
||||
if (x=='any') {
|
||||
x='string' //for json columns
|
||||
}
|
||||
// if (!x.endsWith('[]')) {
|
||||
// x = x + '[]'// can't distinguish OneTwoMany from OneToOne without indexes
|
||||
// }
|
||||
|
Loading…
Reference in New Issue
Block a user