sequelize / sequelize/sequelize

Mysql dialect support for createFunction and dropFunction

Open
#9,806 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: feature
Dominant language
TypeScript
Stars
30.4k
Forks
4.3k
Avg merge
1d 6h
Merged PRs (30d)
68

Description

What are you doing?

// Using a Mysql server...
(sequelize) => {
  const queryInterface = sequelize.getQueryInterface();

  queryInterface.dropFunction('TEST_FUNC').finally(() => {
    queryInterface.createFunction(
      'TEST_FUNC',
      [{name: 'test_param', type: 'VARCHAR(100)', direction: 'IN'}],
      'VARCHAR(100)',
      'SQL',
      'RETURN test_param;',
      ['DETERMINISTIC']
    ).then(
      () => console.log('TEST_FUNC created'),
      (error) => { throw error }
    );
  });
}

What do you expect to happen?

Mysql database acquires the function TEST_FUNC.

What is actually happening?

TypeError: this.QueryGenerator.createFunction is not a function

…and, indeed, there is no createFunction in sequelize/lib/dialects/mysql/query-generator.js.

I needed this for my project, please find my patch for 5.0.0-beta.10 attached.

Dialect: mysql
Dialect version: (5.0.0-beta.10)
Database version: any
Sequelize version: 5.0.0-beta.10
Tested with latest release: Yes

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sequelize/lib/dialects/mysql/query-generator.js and compare the existing dialect implementations of createFunction and dropFunction. Verify the reported sample against MySQL; done means the MySQL query interface supports both operations without the reported TypeError and creates and drops TEST_FUNC.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mysql
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.