php - Wrong table formatting for sqlserver grammar
I am using the Laravel query builder for fetching some data from a sqlsrv database. The table I am looking for is
dbo.[Reukema Blocq Maneschijn BV$Time Slot (Weighbridge)]. Not my choice. The database is developed by an other company.
I keep getting a
General error: 20018 Invalid object name error when executing my query. I double checked the name for typos but I couldn't find one.
What I did find was a problem in compiling the query. This is my code to test the problem:
$query = $connection->query() ->from('Reukema Blocq Maneschijn BV$Time Slot (Weighbridge)') ->toSql()
When I dump the
$query, I get the following:
string(67) "select * from [Reukema Blocq Maneschijn BV$Time Slot ](Weighbridge)"
] is in the wrong place here.
This problem keeps existing, even when I'm using the
$query = $connection->query() ->from($connection->raw('dbo.[Reukema Blocq Maneschijn BV$Time Slot (Weighbridge)]')) ->toSql()
Even in this last example, the
] moves from the end of the string, to just before the
Why is this? Am I missing an important rule/mechanic for compiling sqlsrv queries?
The following code does work. That makes it extra weird for me:
$connection->select('select [Time Slot] as [id] from [Reukema Blocq Maneschijn BV$Time Slot (Weighbridge)]');
So I think there is something wrong in the
[email protected] method. Why does Laravel compile it like this?