diff --git a/src/drivers/AbstractDriver.ts b/src/drivers/AbstractDriver.ts index 29c0d54..aa80300 100644 --- a/src/drivers/AbstractDriver.ts +++ b/src/drivers/AbstractDriver.ts @@ -408,9 +408,7 @@ export default abstract class AbstractDriver { .forEach((col) => { // eslint-disable-next-line no-param-reassign col.primary = true; - if ( - col.options.unique - ) { + if (col.options.unique) { delete col.options.unique; } }); diff --git a/src/drivers/MysqlDriver.ts b/src/drivers/MysqlDriver.ts index 665f5e9..8ce8248 100644 --- a/src/drivers/MysqlDriver.ts +++ b/src/drivers/MysqlDriver.ts @@ -328,8 +328,9 @@ export default class MysqlDriver extends AbstractDriver { ColumnName: string; is_unique: number; is_primary_key: number; + is_fulltext: number; }>(`SELECT TABLE_NAME TableName,INDEX_NAME IndexName,COLUMN_NAME ColumnName,CASE WHEN NON_UNIQUE=0 THEN 1 ELSE 0 END is_unique, - CASE WHEN INDEX_NAME='PRIMARY' THEN 1 ELSE 0 END is_primary_key + CASE WHEN INDEX_NAME='PRIMARY' THEN 1 ELSE 0 END is_primary_key, CASE WHEN INDEX_TYPE="FULLTEXT" THEN 1 ELSE 0 END is_fulltext FROM information_schema.statistics sta WHERE table_schema IN (${MysqlDriver.buildEscapedObjectList( dbNames @@ -351,6 +352,8 @@ export default class MysqlDriver extends AbstractDriver { options: {}, }; if (records[0].is_primary_key === 1) indexInfo.primary = true; + if (records[0].is_fulltext === 1) + indexInfo.options.fulltext = true; if (records[0].is_unique === 1) indexInfo.options.unique = true; records.forEach((record) => { diff --git a/src/models/Index.ts b/src/models/Index.ts index 1f171fa..22ab477 100644 --- a/src/models/Index.ts +++ b/src/models/Index.ts @@ -3,6 +3,7 @@ export type Index = { columns: string[]; options: { unique?: boolean; + fulltext?: boolean; }; primary?: boolean; }; diff --git a/test/integration/github-issues/285/entity/Post.ts b/test/integration/github-issues/285/entity/Post.ts new file mode 100644 index 0000000..be987bb --- /dev/null +++ b/test/integration/github-issues/285/entity/Post.ts @@ -0,0 +1,13 @@ +import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn, Index } from "typeorm"; + +@Index("my_index", ["title"], { fulltext: true }) +@Entity("Post") +export class Post { + + @PrimaryGeneratedColumn() + id: number; + + + @Column("varchar") + title: string; +} diff --git a/test/integration/runTestsFromPath.test.ts b/test/integration/runTestsFromPath.test.ts index c6b9f69..928540b 100644 --- a/test/integration/runTestsFromPath.test.ts +++ b/test/integration/runTestsFromPath.test.ts @@ -199,10 +199,15 @@ function runTestForMultipleDrivers( case "248": return dbDrivers.filter(dbDriver => dbDriver === "postgres" - );case "273": + ); + case "273": return dbDrivers.filter(dbDriver => ["mysql", "mariadb","mssql"].includes(dbDriver) ); + case "285": + return dbDrivers.filter(dbDriver => + ["mysql", "mariadb"].includes(dbDriver) + ); default: return dbDrivers; } diff --git a/test/utils/EntityFileToJson.ts b/test/utils/EntityFileToJson.ts index 2da8ebd..c61dfda 100644 --- a/test/utils/EntityFileToJson.ts +++ b/test/utils/EntityFileToJson.ts @@ -27,6 +27,8 @@ class EntityIndex { public columnNames: string[] = []; public isUnique = false; + + public fulltext = false; } function removeTrailingComas(input: string) { @@ -208,6 +210,9 @@ export default class EntityFileToJson { ind.isUnique = optionsStr.split(":")[1].trim() === "true"; break; + case "fulltext": + ind.fulltext = optionsStr.split(":")[1].trim() === "true"; + break; default: console.log( `[EntityFileToJson:convert] Index option not recognized ${ind.indexName}:`