Skip to content

Commit 82bc4f8

Browse files
authored
Support mass assignment to SQL Server views (#37307)
SqlServerGrammar assumes that the model is backed by a table, but some unfortunate souls attach to views in SQL Server. This revision updates SqlServerGrammar to look for views as well as tables.
1 parent 325699a commit 82bc4f8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class SqlServerGrammar extends Grammar
2929
protected $serials = ['tinyInteger', 'smallInteger', 'mediumInteger', 'integer', 'bigInteger'];
3030

3131
/**
32-
* Compile the query to determine if a table exists.
32+
* Compile the query to determine if a table or view exists.
3333
*
3434
* @return string
3535
*/
3636
public function compileTableExists()
3737
{
38-
return "select * from sysobjects where type = 'U' and name = ?";
38+
return "select * from sysobjects where type in ('U', 'V') and name = ?";
3939
}
4040

4141
/**
@@ -48,7 +48,7 @@ public function compileColumnListing($table)
4848
{
4949
return "select col.name from sys.columns as col
5050
join sys.objects as obj on col.object_id = obj.object_id
51-
where obj.type = 'U' and obj.name = '$table'";
51+
where obj.type in ('U', 'V') and obj.name = '$table'";
5252
}
5353

5454
/**

0 commit comments

Comments
 (0)