Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql.index is not work on property #467

Open
forno opened this issue Jul 8, 2022 · 0 comments
Open

mysql.index is not work on property #467

forno opened this issue Jul 8, 2022 · 0 comments
Labels

Comments

@forno
Copy link
Contributor

forno commented Jul 8, 2022

Steps to reproduce

  1. Create the model, repository, and detasource with @property({type: 'string', mysql: {index: {kind: "FULLTEXT"}}}) on model.
  2. npm run migrate on cli.
  3. It should make FULLTEXT INDEX, however it isn't made on MySQL.

This is example of a model.

// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
// Node module: @loopback/example-todo
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {Entity, model, property} from '@loopback/repository';

@model()
export class Todo extends Entity {
  @property({
    type: 'number',
    id: true,
    generated: false,
  })
  id?: number;


  @property({
    type: 'string',
    required: true,
    // Not work for index creation
    mysql: {
      index: {
        kind: 'FULLTEXT',
      },
    },
  })
  title: string;

  @property({
    type: 'string',
    // work for index creation. but it is diffrent by README
    index: {
      kind: 'FULLTEXT',
      // also it can `unique: true` in here, not mysql.index.unique...
    },
  })
  desc?: string;

  constructor(data?: Partial<Todo>) {
    super(data);
  }
}

export interface TodoRelations {
  // describe navigational properties here
}

export type TodoWithRelations = Todo & TodoRelations;

Current Behavior

@property.mysql.index is not work.

But, I see work with @property.index.

Expected Behavior

We can replace @property.mysql.index with @property.index on README.

class Post {
@property({
type: 'string',
mysql: {
index: {
kind: 'FULLTEXT'
}
},
})
content: string;
}

Or,

Fix the prop.index to prop.mysql.index and m.properties[propName].index; to m.properties[propName].mysql.index; on migration.js.

const i = prop && prop.index;

const i = m.properties[propName].index;

Link to reproduction sandbox

https://github.com/forno/loopback-next/blob/index-bug-report/examples/todo/src/models/todo.model.ts

Additional information

the index creation function are already exist. But it is different config written by README.
I don't know that either is correct.

Related Issues

#350

See Reporting Issues for more tips on writing good issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Icebox
Development

No branches or pull requests

1 participant