[Mssql 2012] Create entity for view #5074

Closed
opened 2026-01-22 14:57:43 +01:00 by admin · 4 comments
Owner

Originally created by @Slavenin on GitHub (Mar 31, 2016).

Originally assigned to: @Ocramius on GitHub.

Hello!
I created view in my db and orm file for it.

Entity\Mssql\Myview:
    type: entity
    table: MyView
    readOnly: true
    id:
        id:
            type: guid
            nullable: false
            length: null
            fixed: false
            id: true
            column: Id
    fields:
        name:
            type: string
            nullable: false
            length: 1024
            fixed: false
            column: Name
        entity:
            type: string
            nullable: false
            length: 12
            fixed: false
            column: entity

but when i run

php app/console doctrine:schema:update --dump-sql

generated sql query for create this table. Problem in vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php in getListTablesSQL and getListTableColumnsSQL in this function select object with type 'U' this phisycal table, view has type = 'V'. This class also has getListViewsSQL method, but i can not find where it using. How i can say doctrine that my entity is view?

Originally created by @Slavenin on GitHub (Mar 31, 2016). Originally assigned to: @Ocramius on GitHub. Hello! I created view in my db and orm file for it. ``` yml Entity\Mssql\Myview: type: entity table: MyView readOnly: true id: id: type: guid nullable: false length: null fixed: false id: true column: Id fields: name: type: string nullable: false length: 1024 fixed: false column: Name entity: type: string nullable: false length: 12 fixed: false column: entity ``` but when i run ``` bash php app/console doctrine:schema:update --dump-sql ``` generated sql query for create this table. Problem in vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php in getListTablesSQL and getListTableColumnsSQL in this function select object with type 'U' this phisycal table, view has type = 'V'. This class also has getListViewsSQL method, but i can not find where it using. How i can say doctrine that my entity is view?
admin added the Invalid label 2026-01-22 14:57:43 +01:00
admin closed this issue 2026-01-22 14:57:44 +01:00
Author
Owner

@Slavenin commented on GitHub (Apr 12, 2016):

Is there anyone alive?

@Slavenin commented on GitHub (Apr 12, 2016): Is there anyone alive?
Author
Owner

@Ocramius commented on GitHub (Apr 12, 2016):

@Slavenin doctrine doesn't understand views at all.
If you want to generate a schema with platform-specific features (in this case a view), then you will have to generate use something like doctrine/migrations and filter out what php app/console doctrine:schema:update --dump-sql gives you, then keep only what is relevant to you in your migration files.

@Ocramius commented on GitHub (Apr 12, 2016): @Slavenin doctrine doesn't understand views at all. If you want to generate a schema with platform-specific features (in this case a view), then you will have to generate use something like [doctrine/migrations](https://github.com/doctrine/migrations) and filter out what `php app/console doctrine:schema:update --dump-sql` gives you, then keep only what is relevant to you in your migration files.
Author
Owner

@postHawk commented on GitHub (Apr 13, 2016):

Ok, but why SQLServerPlatform contains methods for work with views? Perhaps i can create new orm type for view? Something like:

Entity\Mssql\Myview:
    type: entity
    view: MyView
@postHawk commented on GitHub (Apr 13, 2016): Ok, but why SQLServerPlatform contains methods for work with views? Perhaps i can create new orm type for view? Something like: ``` yml Entity\Mssql\Myview: type: entity view: MyView ```
Author
Owner

@Ocramius commented on GitHub (Apr 13, 2016):

@postHawk the schema manager can create views, if needed, but the ORM only deals with tables, for now

@Ocramius commented on GitHub (Apr 13, 2016): @postHawk the schema manager can create views, if needed, but the ORM only deals with tables, for now
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5074