Skip to content

Commit

Permalink
feat: add set datatype support for aurora-data-api (#7665)
Browse files Browse the repository at this point in the history
* adds support for type set to data-api

* adds support for type set to data-api

* fix spacing
  • Loading branch information
SethVerishop committed May 20, 2021
1 parent b9cc9c9 commit b6c1836
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/driver/aurora-data-api/AuroraDataApiDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export class AuroraDataApiDriver implements Driver {
"longblob",
"longtext",
"enum",
"set",
"binary",
"varbinary",
// json data type
Expand Down Expand Up @@ -441,7 +442,7 @@ export class AuroraDataApiDriver implements Driver {
} else if (columnMetadata.type === "timestamp" || columnMetadata.type === "datetime" || columnMetadata.type === Date) {
return DateUtils.mixedDateToDate(value);

} else if (columnMetadata.type === "simple-array") {
} else if (columnMetadata.type === "simple-array" || columnMetadata.type === "set") {
return DateUtils.simpleArrayToString(value);

} else if (columnMetadata.type === "simple-json") {
Expand Down Expand Up @@ -480,7 +481,7 @@ export class AuroraDataApiDriver implements Driver {
} else if (columnMetadata.type === "time") {
value = DateUtils.mixedTimeToString(value);

} else if (columnMetadata.type === "simple-array") {
} else if (columnMetadata.type === "simple-array" || columnMetadata.type === "set") {
value = DateUtils.stringToSimpleArray(value);

} else if (columnMetadata.type === "simple-json") {
Expand Down Expand Up @@ -561,7 +562,10 @@ export class AuroraDataApiDriver implements Driver {
if ((columnMetadata.type === "enum" || columnMetadata.type === "simple-enum") && defaultValue !== undefined) {
return `'${defaultValue}'`;
}
if ((columnMetadata.type === "set") && defaultValue !== undefined) {
return `'${DateUtils.simpleArrayToString(defaultValue)}'`;

}
if (typeof defaultValue === "number") {
return "" + defaultValue;

Expand Down
2 changes: 1 addition & 1 deletion src/driver/aurora-data-api/AuroraDataApiQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ export class AuroraDataApiQueryRunner extends BaseQueryRunner implements QueryRu
tableColumn.scale = parseInt(dbColumn["NUMERIC_SCALE"]);
}

if (tableColumn.type === "enum" || tableColumn.type === "simple-enum") {
if (tableColumn.type === "enum" || tableColumn.type === "simple-enum" || tableColumn.type === "set") {
const colType = dbColumn["COLUMN_TYPE"];
const items = colType.substring(colType.indexOf("(") + 1, colType.lastIndexOf(")")).split(",");
tableColumn.enum = (items as string[]).map(item => {
Expand Down

0 comments on commit b6c1836

Please sign in to comment.