mysql fulltext index base support(#285)
This commit is contained in:
parent
3e29544063
commit
7cae89a9ef
@ -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;
|
||||
}
|
||||
});
|
||||
|
@ -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) => {
|
||||
|
@ -3,6 +3,7 @@ export type Index = {
|
||||
columns: string[];
|
||||
options: {
|
||||
unique?: boolean;
|
||||
fulltext?: boolean;
|
||||
};
|
||||
primary?: boolean;
|
||||
};
|
||||
|
13
test/integration/github-issues/285/entity/Post.ts
Normal file
13
test/integration/github-issues/285/entity/Post.ts
Normal file
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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}:`
|
||||
|
Loading…
Reference in New Issue
Block a user