lucid-slugify icon indicating copy to clipboard operation
lucid-slugify copied to clipboard

Error "sqlMessage": "FUNCTION database.REGEXP_SUBSTR does not exist",

Open petronioamaral opened this issue 3 years ago • 4 comments

Hello there,

When I tried create a new row I got this error.

{ "code": "ER_SP_DOES_NOT_EXIST", "errno": 1305, "sqlState": "42000", "sqlMessage": "FUNCTION database.REGEXP_SUBSTR does not exist", "sql": "select CAST(REGEXP_SUBSTR(slug, '[0-9]+$') AS UNSIGNED) as lucid_slugify_counter fromadvertswhereslugREGEXP '^iphone-celular-12(-[0-9]*)?$' order bylucid_slugify_counterdesc" }

I added in my model

import { BaseModel, column, decimal, BelongsTo, belongsTo, text, HasMany, hasMany } from '@ioc:Adonis/Lucid/Orm' import { slugify } from '@ioc:Adonis/Addons/LucidSlugify'

@column() @slugify({ strategy: 'dbIncrement', fields: ['title'], }) public slug: string @column() public title: string

const data = await Advert.create({ title, price, description })

package.json "devDependencies": { "@adonisjs/assembler": "^5.8.1", "@japa/preset-adonis": "^1.2.0", "@japa/runner": "^2.2.1", "adonis-preset-ts": "^2.1.0", "eslint": "^8.23.1", "eslint-config-prettier": "^8.5.0", "eslint-plugin-adonis": "^2.1.0", "eslint-plugin-prettier": "^4.2.1", "pino-pretty": "^9.1.0", "prettier": "^2.7.1", "typescript": "~4.6", "youch": "^3.2.2", "youch-terminal": "^2.1.5" }, "dependencies": { "@adonisjs/core": "^5.8.0", "@adonisjs/lucid": "^18.1.1", "@adonisjs/lucid-slugify": "^2.2.1", "@adonisjs/repl": "^3.1.0", "luxon": "^3.0.3", "mysql": "^2.18.1", "mysql2": "^2.3.3", "openapi-types": "^12.0.2", "proxy-addr": "^2.0.7", "reflect-metadata": "^0.1.13", "sharp": "^0.31.1", "source-map-support": "^0.5.21" }

Node.js and npm version

v16.17.0

petronioamaral avatar Oct 18 '22 19:10 petronioamaral

Hey @petronioamaral! 👋🏻

What database are you using?

RomainLanz avatar Oct 18 '22 20:10 RomainLanz

Hey @petronioamaral! 👋🏻

What database are you using?

Hello @RomainLanz , mysql 5.7.26

petronioamaral avatar Oct 19 '22 10:10 petronioamaral

The REGEXP_SUBSTR function does not exist in MySQL 5.7. Update to version 8.

RomainLanz avatar Oct 19 '22 19:10 RomainLanz

Or, you will have to specify the MySQL version in the config file for this package to know which version you are using.

{
  client: 'mysql', // or mysql2
  version: '5.7'
}

thetutlage avatar Oct 20 '22 05:10 thetutlage

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 23 '22 17:12 stale[bot]