Skip to content

Commit a37f80d

Browse files
committed
replace binary and varbinary types by varchar
1 parent 9e4de29 commit a37f80d

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/client/compiler/parser/Parser.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,8 @@ export class Parser {
12741274
this.module.addCompletionHint(this.getEndOfPosition(pos0), pos1, hintColumns, hintTables, hints, null, praefix, suffix);
12751275
}
12761276

1277+
identifierMap: {[key: string]:string} = {'year': 'int', 'binary': 'varchar', 'varbinary': 'varchar'};
1278+
12771279
parseType(node: CreateTableColumnNode, primaryKeyAlreadyDefined: boolean) {
12781280

12791281
let datatypes = SQLBaseType.baseTypes.map(type => type.toString());
@@ -1285,8 +1287,10 @@ export class Parser {
12851287
}
12861288

12871289
let identifier = <string>this.cct.value;
1288-
if (identifier.toLowerCase() == 'year') {
1289-
identifier = 'int';
1290+
let mappedIdentifier:string = this.identifierMap[identifier.toLocaleLowerCase()];
1291+
1292+
if (mappedIdentifier != null) {
1293+
identifier = mappedIdentifier;
12901294
}
12911295

12921296
let type = SQLBaseType.getBaseType(identifier);
@@ -1399,7 +1403,7 @@ export class Parser {
13991403
}
14001404

14011405
node.defaultValue = <string>this.cct.value;
1402-
if (typeof this.cct.value == "string") {
1406+
if (typeof this.cct.value == "string" && node.defaultValue.toLowerCase() != 'null' ) {
14031407
node.defaultValue = "'" + node.defaultValue + "'";
14041408
}
14051409
//@ts-ignore
@@ -1551,9 +1555,14 @@ export class Parser {
15511555
if (this.tt == TokenType.identifier) {
15521556
if (this.cct.isDoubleQuotedIdentifier) {
15531557
this.tt = TokenType.stringConstant
1554-
} else if ((this.cct.value + "").toLocaleLowerCase() == "date") {
1555-
this.nextToken();
1558+
} else {
1559+
let lv = (this.cct.value + "").toLocaleLowerCase();
1560+
if (["date", "_binary"].indexOf(lv) >= 0) {
1561+
this.nextToken();
1562+
}
15561563
}
1564+
1565+
15571566
}
15581567

15591568

0 commit comments

Comments
 (0)