Closed dkuzevanov closed 5 years ago
Looks like uncontrolled recursion in \Illuminate\Database\Query\Grammars\Grammar::wrap()
method.
@staudenmeir didn't we experience this issue before?
@driesvints This is a different issue. It's caused by Laravel and affects all databases. I'll look into it.
@staudenmeir thanks!
This points to a bigger problem that Laravel cannot support tables with .
in their names, although it is supported by SQL Databases.
@CurosMJ We can't really support dots in table names because we can't differentiate between database.table
and table.with.dots
.
@staudenmeir Yes that's true.
Also, to correct my previous comment, MySQL does not allow table and database names with .
in them. @dkuzevanov Does SQL Server allow this?
@CurosMJ MySQL does support it if you quote the table name:
select * from `table.with.dots`
@driesvints I couldn't find a good solution and I suggest that we close this as "not supported".
It's an extreme edge case and not really good practice to have table names with dots. Even with a fix, only the table prefix could contain dots but not the "main" table name (https://github.com/laravel/framework/issues/28307#issuecomment-491324905).
Yeah, I think this is going to be impossible to fix. But we could change it in a major release if enough people would want it to be supported. Thanks for looking into it š
It feels somewhat hacky but I was able to pass in a table with a dot in the name by providing an \Illuminate\Database\Query\Expression
as the argument.
Eg.
$table = (new Expression('`tablename.with.dots`'));
dd( DB::table($table)->count() ); // works
It feels somewhat hacky but I was able to pass in a table with a dot in the name by providing an
\Illuminate\Database\Query\Expression
as the argument. Eg.$table = (new Expression('`tablename.with.dots`')); dd( DB::table($table)->count() ); // works
It might be long overdue but I second your answer.
Looks like by passing it as an expression it bypasses the wrap method
Which somehow ends in an infinite callback between the wrapTable and wrapSegments methods. This is all started by the compileFrom method.
@staudenmeir or @bAngerman I did not have much time to investigate but I think this might be a bug, mind looking into it? I will too when I will have time.
Edit: Laravel 11 looks like it supports it, lol Sauce: https://github.com/laravel/framework/blob/6089f679d6d29e6071a6448ed5e96de02e57fedb/src/Illuminate/Database/Grammar.php#L60
I came back after exploring what is happening, it looks like it gets stuck in an infinite loop and eventually it Seg faults.
Here is the simplified flow of what is happening if your prefix has dots in it "prefix.prefix.blabla"
Description:
Something goes wrong while using tables prefix with dot (when trying to get data from tables like
sys.server_principals
via model). As a result we gotSegmentation fault
. Thegdb
showed that last call ismb_strpos
:By debug i found place in the code that corresponds
gdb
trace:Steps To Reproduce:
Illuminate\Database\Eloquent\Builder
.