Unrecognized option "mapping_types" by multiple connections
Asked Answered
L

2

7

I'm trying to add the "enum" type to my symfony2 dbal connection, but I can't find a way to do it.

doctrine:
    dbal:
        mapping_types:
            enum: string
        default_connection: default
        connections:
            default:
                  driver:   "%database_driver%"
                  host:     "%database_host%"
                  port:     "%database_port%"
                  dbname:   "%database_name%"
                  user:     "%database_user%"
                  password: "%database_password%"
                  charset:  UTF8
            connection2:
                  driver:   "%database2_driver%"
                  host:     "%database2_host%"
                  port:     "%database2_port%"
                  dbname:   "%database2_name%"
                  user:     "%database2_user%"
                  password: "%database2_password%"
                  charset:  LATIN1

This is my config right now and I'm getting the error:

  [Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]  
  Unrecognized option "mapping_types" under "doctrine.dbal"    

I also tried to place it beneath the connection2 and removed the default_connection since I found answers that solved the problem like this. But these questions haven't had multiple connections.

Lisette answered 5/5, 2015 at 8:59 Comment(0)
B
14

mapping_types must be located under concrete connection. So you need next config:

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                  mapping_types:
                      enum: string
                  driver:   "%database_driver%"
                  host:     "%database_host%"
                  port:     "%database_port%"
                  dbname:   "%database_name%"
                  user:     "%database_user%"
                  password: "%database_password%"
                  charset:  UTF8
            connection2:
                  mapping_types:
                      enum: string
                  driver:   "%database2_driver%"
                  host:     "%database2_host%"
                  port:     "%database2_port%"
                  dbname:   "%database2_name%"
                  user:     "%database2_user%"
                  password: "%database2_password%"
                  charset:  LATIN1
Businesslike answered 5/5, 2015 at 9:8 Comment(2)
You are correct, but this is not how the Symfony docs described the Doctrine configuration. See symfony.com/doc/3.3/reference/configuration/…. The example clear shows mapping_types within doctrine.dbal itself.Zebe
@JasonGabler, in the provided documentation there is no information about where key mapping_types live if there exist several connections. But you can draw an analogy with other keys from connection. The key mapping_types depends on connection in the same way as driver or host so they should be at one block under concrete connection.Businesslike
L
1

in according with the full reference, you must set the mapping_typesunder the specified connection element.

Check here for further detail

hope this help

Lynnell answered 5/5, 2015 at 9:6 Comment(1)
You are correct, but this is not how the Symfony docs described the Doctrine configuration. In the link to the Symfony docs you provide, the example clear shows mapping_types within doctrine.dbal itself.Zebe

© 2022 - 2024 — McMap. All rights reserved.