Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db.raw() in ColumnOptions.prepare works for insert but not for update #1079

Open
BluemediaDev opened this issue Dec 17, 2024 · 2 comments
Open
Assignees
Labels
Type: Enhancement Improving an existing feature

Comments

@BluemediaDev
Copy link

Package version

@adonisjs/[email protected]

Describe the bug

Hi everyone,

I've encountered the same issue described in #939 while using the latest Lucid release. My use case and the resulting error closely mirror those in the original issue.

I attempted to create a test case to address this, but my understanding of Lucid's internals is limited. Instead, I put together a small reproduction repository to demonstrate the problem.

Feel free to let me know if additional details or adjustments are needed!

Reproduction repo

https://github.com/BluemediaDev/lucid-prepare-repro

@thetutlage
Copy link
Member

Hello @BluemediaDev

I think the root of the issue is how the prepare method works right now. Basically, the prepare method is not capable of returning different values for insert, update, or select.

I am afraid that there is no quick fix for this and this is something we will have to think a bit more and then add support for it. I will keep this issue opened until we work on that.

@thetutlage thetutlage self-assigned this Dec 18, 2024
@thetutlage thetutlage added the Type: Enhancement Improving an existing feature label Dec 18, 2024
@BluemediaDev
Copy link
Author

Hi @thetutlage,

Thank you for looking into this!

I might be missing something about how Lucid works internally, but in my view, it doesn't seem necessary to return different values for different actions in this case. POINT() should work for INSERT, UPDATE, and SELECT operations without issue.

The error appears to be more about the RawBuilder not being properly converted into valid SQL and used in the query—it looks like it's just dumped as text instead. I enabled the debug mode on the reproduction repo; maybe that makes it clearer what I'm talking about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Improving an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants