lucid
lucid copied to clipboard
db.raw() in ColumnOptions.prepare works for insert but not for update
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
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.
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.
i'm facing the same issue any updates @thetutlage
@MohammedElattar This will require a bit more planning since the column.prepare was build for simple use-cases. I do not have a solution at hand right now. However, in the next major release, I will address this shortcoming
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.