You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are in the process of migrating to Singlestore and have encountered a compatibility issue with Laravel's Database Notifications.
The issue arises from the HasDatabaseNotifications trait, which defines a relationship that automatically applies a latest sorting order by default. This sorting behavior is intended for notification retrieval but also inadvertently affects deletion operations. While this automatically generated query functions correctly in MySQL and PostgreSQL, it appears that Singlestore does not support this syntax.
HasDatabaseNotification Trait and Relation
<?phpnamespaceIlluminate\Notifications;
traitHasDatabaseNotifications
{
/** * Get the entity's notifications. * * @return \Illuminate\Database\Eloquent\Relations\MorphMany */publicfunctionnotifications()
{
return$this->morphMany(DatabaseNotification::class, 'notifiable')->latest();
}
Example of a produced query when trying to delete a notification via relation and the corresponding error from Singlestore
deletefrom`notifications`where`notifications`.`notifiable_type`= App \ Models \ User
and`notifications`.`notifiable_id`=218and`notifications`.`notifiable_id`is not nulland JSON_EXTRACT_STRING(data, 'format') = filament
and`id`= 9bf43012 - ecff - 4ef1 - afb2 - 26ee0218109f
order by`created_at`desc
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by `created_at` desc' at line1
@carlsverre the behaviour should be documented in Singlestores doc. In the example is a order by in a subquery but no mention of the not allowed behaviour.
Hey @Cosnavel
Thanks for pointing out this incompatibility.
With your changes, the connector may produce an incorrect result.
For example, when someone wants to delete a single row with the latest timestamp (without order by, it will delete the random row, which will be very unexpected).
I prefer to throw an error in this case by default and add a special flag ignore_order_by_in_delete which can be enabled in the case of migrations when the user knows that order by can be safely ignored.
Hey @AdalbertMemSQL,
would also be an idea to overwrite the entire handling of the order by in deletes and inject it as a subquery. Would that be possible?
We also encountered several errors because of subqueries like this so in a bit concerned.
General error: 1749 Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed.
Hmm....
I think that in some cases (when the table has a unique key) it should be possible.
But I'm not sure about the performance of such queries.
I need to investigate it deeper.
Are you blocked by this feature? I can work on enabling a possibility to ignore order by in deletes and then work on the investigation of implementing this functionality as subselects.
Can you open a separate issue regarding subqueries with examples of queries that caused this error?
We are in the process of migrating to Singlestore and have encountered a compatibility issue with Laravel's Database Notifications.
The issue arises from the HasDatabaseNotifications trait, which defines a relationship that automatically applies a
latest
sorting order by default. This sorting behavior is intended for notification retrieval but also inadvertently affects deletion operations. While this automatically generated query functions correctly in MySQL and PostgreSQL, it appears that Singlestore does not support this syntax.HasDatabaseNotification Trait and Relation
Example of a produced query when trying to delete a notification via relation and the corresponding error from Singlestore
@carlsverre the behaviour should be documented in Singlestores doc. In the example is a order by in a subquery but no mention of the not allowed behaviour.
Reference: https://docs.singlestore.com/cloud/reference/sql-reference/data-manipulation-language-dml/delete/#example
@olliescase
The text was updated successfully, but these errors were encountered: