Skip to content

Explicitly use parameter binding to prevent generating mangled FQN pr… #32

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

Merged
merged 4 commits into from
Mar 28, 2025

Conversation

drsdre
Copy link
Contributor

@drsdre drsdre commented Mar 14, 2025

I ran into a blocking issue where non of the time series were retrieved. It turned out that in the projection name queries the backslashes from the FQCN were interpreted as character escapes. This caused a search for App\Models\Model to become a search for AppModelsModel hence nothing got retrieved.

This patch explicitly tells eloquent to use database resolved parameter bindings. With parameter binding the database will figure out if the value should be escaped or not. The tests are still green with this change.

Probably the reason why the tests were green before had to do with Sqlite not doing character escaping whilst MariaDB/MySQL does.

drsdre and others added 2 commits March 14, 2025 07:03
…ojection names because of backslash escaping i.e. prevent App\Models\Class to AppModelsClass.
Retrieving the projection also requires a whereRaw to handle the backslashes in the projection_name. The updated_at field should be used to determine the start_date as not the created_at.
@timothepearce
Copy link
Owner

@drsdre We have some regressions on the test with your last commit. Not sure your change will fix the problem.
Can you output the faulty SQL query and the one you'll have after your change?

Thanks for your contribution!

@drsdre
Copy link
Contributor Author

drsdre commented Mar 28, 2025

One other fix slipped into this pull request which probably should have been kept in a separate pull request.

I found an issue where the start_date was set not changing when the projected record got updated. It turns out that the created_at date is used to determine the start date. When records are updated, the updated_at should be used to reflect the change and map it to the right time period. With the latest commit, I've updated the test to also set the updated_at in the test model as it normally is done also by Eloquent. This makes the test green again.

@timothepearce timothepearce merged commit e6f4675 into timothepearce:main Mar 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants