diff --git a/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php b/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php index d15a32f3cbe7..9d811153829d 100755 --- a/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php @@ -125,7 +125,7 @@ public function compileColumns($schema, $table) .'join sys.schemas as scm on obj.schema_id = scm.schema_id ' .'left join sys.default_constraints def on col.default_object_id = def.object_id and col.object_id = def.parent_object_id ' ."left join sys.extended_properties as prop on obj.object_id = prop.major_id and col.column_id = prop.minor_id and prop.name = 'MS_Description' " - .'left join sys.computed_columns as com on col.column_id = com.column_id ' + .'left join sys.computed_columns as com on col.column_id = com.column_id and col.object_id = com.object_id ' ."where obj.type in ('U', 'V') and obj.name = %s and scm.name = %s " .'order by col.column_id', $this->quoteString($table), diff --git a/tests/Integration/Database/SqlServer/DatabaseSqlServerSchemaBuilderTest.php b/tests/Integration/Database/SqlServer/DatabaseSqlServerSchemaBuilderTest.php index f332de17fcd2..501bed559c34 100644 --- a/tests/Integration/Database/SqlServer/DatabaseSqlServerSchemaBuilderTest.php +++ b/tests/Integration/Database/SqlServer/DatabaseSqlServerSchemaBuilderTest.php @@ -21,6 +21,7 @@ protected function afterRefreshingDatabase() protected function destroyDatabaseMigrations() { Schema::drop('users'); + Schema::dropIfExists('computed'); DB::statement('drop view if exists users_view'); } @@ -64,4 +65,12 @@ public function testGetViewsWhenNoneExist() { $this->assertSame([], Schema::getViews()); } + + public function testComputedColumnsListing() + { + DB::statement('create table dbo.computed (id int identity (1,1) not null, computed as id + 1)'); + + $userColumns = Schema::getColumns('users'); + $this->assertNull($userColumns[1]['generation']); + } }