adonisjs / auth

Official Authentication package for AdonisJS
https://docs.adonisjs.com/guides/auth/introduction
MIT License
187 stars 65 forks source link

`returning` is not supported by mysql #241

Closed sooluh closed 3 months ago

sooluh commented 4 months ago

Package version

9.1.1

Describe the bug

I saw the following 2 codes here,

https://github.com/adonisjs/auth/blob/016cc8c6a27109597d86c37caa81a5cf793f529a/modules/access_tokens_guard/token_providers/db.ts#L175-L176

https://github.com/adonisjs/auth/blob/016cc8c6a27109597d86c37caa81a5cf793f529a/modules/session_guard/token_providers/db.ts#L145-L146

It is noticed that the method/function returning('id') is used there, which is not supported for MySQL by knex itself ^1. 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

thetutlage commented 4 months ago

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

sooluh commented 4 months ago

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

thetutlage commented 3 months ago

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.

sooluh commented 3 months ago

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.