Skip to content

Asset sorting by size not functioning correctly #420

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

Open
RyanDrewniak opened this issue Apr 9, 2025 · 3 comments
Open

Asset sorting by size not functioning correctly #420

RyanDrewniak opened this issue Apr 9, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@RyanDrewniak
Copy link

RyanDrewniak commented Apr 9, 2025

Bug description

My site is using the eloquent driver for asset handling. I have nested files/folders which I am trying to sort by "Size". When doing so, I get incorrect results. Here's a screenshot of what I'm seeing:

Image

The query that I'm seeing from my instance of the debug bar looks like this:

select * from `assets_meta` where `container` = 'assets' and `folder` = 'partners' order by json_unquote(json_extract(`meta`, '$."size"')) asc limit 5 offset 0;

I have tried this on 2 other sites all using Statamic 5 with the latest version of the eloquent-driver, and all of them are getting the same kinds of results.

I also tried switching back to the file system, and when I did that, the sorting by size worked perfectly fine.

How to reproduce

Ensure that your eloquent-driver.php config file has the asset_container and assets drivers set to eloquent.

Logs

No response

Environment

Environment
Application Name: *********
Laravel Version: 11.44.2
PHP Version: 8.2.27
Composer Version: 2.8.4
Environment: local
Debug Mode: ENABLED
URL: *********.test
Maintenance Mode: OFF
Timezone: America/Edmonton
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: redis
Database: mysql
Logs: stack / single, slack
Mail: mailgun
Queue: redis
Session: redis

Livewire
Livewire: v3.6.2

Laravel-Modules
Version: v11.1.10

Sentry
Enabled: MISSING DSN
Environment: local
Laravel SDK Version: 4.13.0
PHP SDK Version: 4.10.0
Release: NOT SET
Sample Rate Errors: 100%
Sample Rate Performance Monitoring: NOT SET
Sample Rate Profiling: NOT SET
Send Default PII: DISABLED

Statamic
Addons: 7
Sites: 5 (*********, *********, *********, *********, *********)
Stache Watcher: Disabled
Static Caching: Disabled
Version: 5.51.0 PRO

Statamic Addons
alt-design/alt-redirect: 1.6.3
jacksleight/statamic-bard-mutator: 3.0.3
jacksleight/statamic-bard-texstyle: 3.4.1
mitydigital/sitemapamic: 3.2.0
statamic/eloquent-driver: 4.21.0
stillat/antlers-components: 2.5.0
teamnovu/statamic-unused-assets: 2.0.2

Statamic Eloquent Driver
Asset Containers: eloquent
Assets: eloquent
Blueprints: file
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: eloquent
Sites: file
Taxonomies: eloquent
Terms: eloquent
Tokens: file

Additional details

No response

@RyanDrewniak RyanDrewniak added the bug Something isn't working label Apr 9, 2025
@ryanmitchell
Copy link
Contributor

This feels similar to #416 in that its sorting based on it being a string, not an integer.

@RyanDrewniak
Copy link
Author

I think that makes sense @ryanmitchell

The downside there though is that it looks like the map_data_to_columns option is only available for the Entries model at the current time: https://github.com/statamic/eloquent-driver?tab=readme-ov-file#using-dedicated-columns-for-data

What are the odds that the size could be split out into a separate column within the eloquent-driver package?

@ryanmitchell
Copy link
Contributor

What are the odds that the size could be split out into a separate column within the eloquent-driver package?

I'd prefer not to do that as it would mean doing this for all of the meta columns, and it doesn't solve the issue when you have a numeric column in your blueprint. We need to come up with a more generalised solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants