Nodejs: Identity returned by Insert is 0

Wappler Version : 5.2.2
Server Model: node js
Database Type: mariadb

There is a table with a uuid:
1 2

There is an action of inserting a new record:
3

But after insertion, instead of the correct uuid, 0 is always returned:
5

I read this topic:

I checked my json file, it turned out to be ok:
4

I have not used UUID’s so I may be wrong in my theory.

The first thing that I noticed is that you are using UUID for the ID of the field. Normally the field ID would be an integer of 4 bytes which makes indexing a simple matter. UUID’s are 36 bytes which requires extra memory to index.

Secondly, you need to create the value of the UUID before it can be inserted into the database as shown in

I hope this helps.

Knex is a 3rd party library that we use for database connections within NodeJS. However knex currently doesn’t support returning for MariaDB database. Knex uses LAST_INSERT_ID() to get the identity in MySQL and MariaDB, it returns the first column which has AUTO_INCREMENT on it. The latest MariaDB supports returning, its only the library that didn’t implement this.

Do I understand correctly that due to the fact that Knex does not support returning the uuid in MySQL/MariaDB, it is impossible to get the uuid of the inserted record in Wappler today?

I’ve checked with Knex again to see if there is some progression, seems they didn’t go any further with it. There was a PR last year for it but it was not accepted. I will investigate if we can work around it.

Is there a workaround.

The only workaround is using a custom query