Skip to content

Implement Builder::toSql using JSON representation of the MQL #2931

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

Closed
wants to merge 2 commits into from

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented May 3, 2024

Fix #2797

The method toSql is used by third party packages like rappasoft/laravel-liveware-tables.

Checklist

  • Add tests and ensure they pass
  • Add an entry to the CHANGELOG.md file
  • Update documentation for new features

@GromNaN GromNaN requested a review from a team as a code owner May 3, 2024 16:02
@GromNaN GromNaN requested a review from jmikola May 3, 2024 16:02
@@ -1535,4 +1546,10 @@ public function orWhereIntegerNotInRaw($column, $values, $boolean = 'and')
{
throw new BadMethodCallException('This method is not supported by MongoDB');
}

/** @internal This method is not supported by MongoDB. */
public function insertUsing(array $columns, $query)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We relied on the exception thrown by the parent method that uses toSql.

* Return the JSON representation of the MongoDB Query.
* Naming is inherited and used for compatibility with third-party packages.
*
* @internal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this still be @internal?

I don't have enough context to understand how/why rappasoft/laravel-livewire-tables needs to support MongoDB, but isn't there some concern that returning JSON strings here might break other packages that expect these methods to return actual SQL statements?

My thinking is that packages wishing to support this library should be the ones to change and conditionally call toMql().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used for debugging: https://tables.laravel-boilerplate.com/tailwind
But Laravel Debugbar would provide the same information.

And I agree this can lead to other problems if packages expect SQL and use the returned value as such.

@GromNaN GromNaN closed this May 6, 2024
@GromNaN GromNaN deleted the toSql branch May 6, 2024 18:49
@GromNaN GromNaN added this to the 4.4 milestone May 22, 2024
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.

toSql() Alias from toMql()
2 participants