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

[5.0] Add dropIfExists() support for SQL Server #8397

Merged
merged 1 commit into from
Apr 12, 2015

Conversation

akurtz
Copy link
Contributor

@akurtz akurtz commented Apr 12, 2015

SQL Server is currently the only driver lacking dropIfExists() support, giving no warning when it is used. This solution was tested on Windows Server 2012 running SQL Server 2014 and should be compatible with SQL Server going all the way back to v7.

The other drivers use $this->wrapTable($blueprint) which wraps the table name in double quotes. SQL Server choked on this, so I've used $blueprint->getTable() instead. Hope that won't be a problem.

See this StackOverflow discussion for more details.

SQL Server is currently the only driver lacking dropIfExists() support, giving no warning when it is used.  This solution was tested on Windows Server 2012 running SQL Server 2014 and should be compatible with SQL Server going all the way back to v7.

The other drivers use `$this->wrapTable($blueprint)` which wraps the table name in double quotes.  SQL server choked on this, so I've used `$blueprint->getTable()` instead.  Hope that won't be a problem.

See [this StackOverflow discussion](http://stackoverflow.com/a/14290099/161752) for more details.
@GrahamCampbell GrahamCampbell changed the title Add dropIfExists() support for SQL Server [5.0] Add dropIfExists() support for SQL Server Apr 12, 2015
taylorotwell added a commit that referenced this pull request Apr 12, 2015
[5.0] Add dropIfExists() support for SQL Server
@taylorotwell taylorotwell merged commit 30ae125 into laravel:5.0 Apr 12, 2015
@akurtz akurtz deleted the patch-1 branch April 12, 2015 19:35
@vlakoff
Copy link
Contributor

vlakoff commented Nov 5, 2016

@akurtz Did the double quotes not work because you had SET QUOTED_IDENTIFIER OFF, or are there other reasons?

I don't understand the issue with double quotes, considering almost everything wouldn't work with SET QUOTED_IDENTIFIER OFF, as Laravel uses everywhere double quotes for SQL Server.

@vlakoff
Copy link
Contributor

vlakoff commented Nov 5, 2016

I think I have guessed. Indeed you had to use getTable() in the WHERE clause (single quote escaping), but you also used it for the DROP TABLE clause, where wrapTable() would have been fine.

refs #13458

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.

4 participants