adonisjs/auth

`returning` is not supported by mysql

Opened this issue · 4 comments

Package version

9.1.1

Describe the bug

I saw the following 2 codes here,

const result = await queryClient.table(this.table).insert(dbRow).returning('id')
const id = this.#isObject(result[0]) ? result[0].id : result[0]

const result = await queryClient.table(this.table).insert(dbRow).returning('id')
const id = this.#isObject(result[0]) ? result[0].id : result[0]

It is noticed that the method/function returning('id') is used there, which is not supported for MySQL by knex itself 12. I know this is for returning an "identifier", but in the previous version (for Adonis v5), there was no identifier and it worked fine.

Is there a fix for this?

Reproduction repo

No response

Footnotes

  1. https://knexjs.org/guide/query-builder.html#returning

  2. https://github.com/knex/knex/issues/2075

Hey, it this a MySQL 5.7 related issue? Because we have tests running for MySQL 8 and everything seems to be fine.

The version of MySQL I'm using (more precisely, I'm using MariaDB).

mysql  Ver 15.1 Distrib 10.6.16-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper

And I tried the RETURNING query myself and it worked. Honestly, I don't know which part isn't supported, but I've seen documentation and issues related to Knex regarding this matter (as per footnotes).

returning query

I am not able to reproduce it. I will recommend creating a failing test in this repo and then I can look into pushing a fix.

I found the issue, @thetutlage! It's because I used UUID (char(36)) on the access_auth_tokens table. I switched it to bigint and it's working fine now. Hopefully UUID will be supported here.