Wappler 6.8.0 "rule.value.replace is not a function"

Wappler Version : 6.8.0
Operating System : MacOS 14.6.1
Server Model: NodeJS v20.17.0
Database Type: MySQL
Hosting Type: MAMP Pro

Expected behavior

What do you think should happen?

Display multiple results for a multi-word search

Actual behavior

What actually happens?

Server 500 error: TypeError: rule.value.replace is not a function

How to reproduce

  • Detail a step by step guide to reproduce the issue

Before the 6.8.0. update it worked fine considering the split function.
It used to work without any problem, in fact the online version that I haven't updated works like that.

2024-08-26_15-12-33

Now I got this:

	"TypeError: rule.value.replace is not a function\n    at QueryBuilder_MySQL.whereGroup (/Users/agmichaca/Developments/auto2024/lib/core/db.js:57:47)\n    at QueryBuilder_MySQL.fromJSON (/Users/agmichaca/Developments/auto2024/lib/core/db.js:181:14)\n    at QueryBuilder_MySQL.<anonymous> (/Users/agmichaca/Developments/auto2024/lib/core/db.js:78:18)\n    at compileCallback (/Users/agmichaca/Developments/auto2024/node_modules/knex/lib/formatter/formatterUtils.js:7:12)\n    at wrap (/Users/agmichaca/Developments/auto2024/node_modules/knex/lib/formatter/wrappingFormatter.js:85:9)\n    at get tableName [as tableName] (/Users/agmichaca/Developments/auto2024/node_modules/knex/lib/query/querycompiler.js:1472:11)\n    at QueryCompiler_MySQL.onlyJson (/Users/agmichaca/Developments/auto2024/node_modules/knex/lib/query/querycompiler.js:800:13)\n    at QueryCompiler_MySQL.columns (/Users/agmichaca/Developments/auto2024/node_modules/knex/lib/query/querycompiler.js:313:25)\n    at /Users/agmichaca/Developments/auto2024/node_modules/knex/lib/query/querycompiler.js:135:40\n    at Array.forEach (<anonymous>)\n    at QueryCompiler_MySQL.select (/Users/agmichaca/Developments/auto2024/node_modules/knex/lib/query/querycompiler.js:134:16)\n    at QueryCompiler_MySQL.toSQL (/Users/agmichaca/Developments/auto2024/node_modules/knex/lib/query/querycompiler.js:75:29)\n    at QueryBuilder_MySQL.toSQL (/Users/agmichaca/Developments/auto2024/node_modules/knex/lib/query/querybuilder.js:84:44)\n    at ensureConnectionCallback (/Users/agmichaca/Developments/auto2024/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:4:30)\n    at Runner.ensureConnection (/Users/agmichaca/Developments/auto2024/node_modules/knex/lib/execution/runner.js:318:20)\n    at async Runner.run (/Users/agmichaca/Developments/auto2024/node_modules/knex/lib/execution/runner.js:30:19)"

If I removed the Split function works, but only with one word.

2024-08-26_15-24-17

Hi Andres,

May not be of relevance but what MySQL driver are you running locally? And what version is on the remote host?

Also a quick search produces this result that may be of interest?

The "TypeError: replace is not a function" error occurs when we call the replace() method on a value that is not of type string.

To solve the error, convert the value to a string, or check if the value is of type string before calling the replace() method.

The reason I asked about the MySQL driver is there are some changes with the newer driver. In your connection settings do you have the depreciated driver set remotely out of interest? This will show in your Target settings. Again can you see if this matches your local configuration? ie is it the depreciated driver running locally or not..?

No idea if any of that helps...

For curiosity is $_GET.q a non-empty value?

If it's an undefined value then some Wappler change made the split formatter stop working with undefined (or null) values

You could test this by adding the .default formatter before the split, but if you confirm this then it's best the Wappler team to fix this as it's a breaking behaviour

Hi Cheese, thanks for your answer.

I got MySQL/Maria DB in both cases. It's already a string, but I tried converting it and is the same,

Hi, $_GET.q is not an empty value.

I just add the .default and it works

$_GET.q.default(split('+'))

But only works with one value

This one dosen´t work, I got and empty result.

http://localhost:3000/api/pagina/porsku?q=renault+scala

Small correction:

$_GET.q.default('').split('+')

The contains condition only accepts a string and not an array. It generates a LIKE statement in SQL.

With the correction I got:

"TypeError: rule.value.replace is not a function

I've tried with IN and got error too.

The problem is that now, with this version, only works with the .default('')

How?

But not the way you want, right? So it doesn't work...

P.S.: I'm just asking the questions for Patrick to help you better

With the IN works only one result without .default

2024-08-27_11-39-30

Thank you Apple

Know that contains and in do something completely different.

contains looks if a string is part of the data in the column, like when q is " hello" it will match when the column would have "hello world" as data.

in looks if the data of the column is within the collection you supply, like when q is ["hello", "world"] it will not match "hello world" but will match "hello" or "world" as column data, the data must exactly match.