Skip to content

Conversation

@calmdev
Copy link

@calmdev calmdev commented Aug 5, 2025

The method annotation expects an array to be returned. The SQL executed by the method also had a typo.

We're seeing this issue on a 1.2.x tagged release, but still seems relevant in main. Any chance we can have this patch back-ported to those earlier releases using an older version of illuminate/database?

Return Type Issue

Reproduce:

// Truncate a model using a snowflake connection
Country::on('snowflake')->truncate();

Result:

Psy Shell v0.11.15 (PHP 8.2.28 — cli) by Justin Hileman
> Country::on('snowflake')->truncate();

   WARNING  foreach() argument must be of type array|object, string given in vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php on line 3585.

= Illuminate\Database\Eloquent\Builder {#8554}

Solution:

Return an array to fix the warning.

SQL Typo Issue

Reproduce (after fixing previous issue):

// Truncate a model using a snowflake connection
Country::on('snowflake')->truncate();

Result:

Psy Shell v0.11.15 (PHP 8.2.28 — cli) by Justin Hileman
> Country::on('snowflake')->truncate();

   Illuminate\Database\QueryException  SQLSTATE[42000]: Syntax error or access violation: 1003 SQL compilation error:
syntax error line 1 at position 0 unexpected 'trunate'. (Connection: snowflake, SQL: trunate table "countries").

Solution:

Replace typo `trunate` with `truncate`.

The method annotation expects an array to be returned.
The SQL executed by the method also had a typo.
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.

1 participant