Skip to content
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

Square brackets not in the table name of SQL query #13435

Closed
dotnet54 opened this issue May 5, 2016 · 1 comment
Closed

Square brackets not in the table name of SQL query #13435

dotnet54 opened this issue May 5, 2016 · 1 comment

Comments

@dotnet54
Copy link

dotnet54 commented May 5, 2016

I keep getting this error

[Illuminate\Database\QueryException]
SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near the keyword 'user'. (SQL: if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'user') drop table user)
[PDOException]
SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near the keyword 'user'.

I think the problem is SQL query says
"if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'user') drop table user" and user happens to be a keyword in SQL Server.

it should add square brackets to the table name right? as in

"if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'user') drop table [user]"

pls confirm if this happens to others?

(edit... btw i was using this function in Laravel 5.2)

Schema::dropIfExists('user');

@fernandobandeira
Copy link
Contributor

Created a PR to fix this issue, its just a small fix...

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

No branches or pull requests

3 participants