Thanks for your answer.
Maybe I haven't communicated well enough. Out test servers are indeed
different servers, completely separated but their database names are
different than in production. It is something that would be very hard to
change in the organization at this point.
Also imagine the following scenario: developers are running integration
tests on their dev machines, they need to run them against different
database names than their standard development ones, since they will loose
all the data when the clean up after tests is done. Hardcoding the schema
name in the entity causes the test to reference their local "live" database
name instead of configured test one.
My question is do you think that when I put the schema name in the entity
annotation, this schema name will be expanded to the correct connection
depending on the configured environment or will explicit database name be
used?
Imagine the dql:
$this->getEntityManager()->createQuery('SELECT c, i
FROM Contact c
LEFT JOIN Inventory i WHERE i = 1
ORDER BY c.id DESC'
the Inventory entity has the following schema reference:
@ORM\Table(schema="seconddb", name="secondtable")
Is DQL going to just use seconddb.secondtable in the query or is it going
to take into the account connection that the Inventory entity repository
has been told to use?
Thanks
A.
On Monday, 22 February 2016 09:36:06 UTC, Marco Pivetta wrote:
>
> I have no clue about debugging symfony apps: if you think that you found
> an ORM bug, you should write a test case against the ORM test suite instead.
>
> I strongly suggest using an environment-variable based switch and use a
> ***COMPLETELY DIFFERENT SERVER*** (that can't even talk to production) when
> running integration tests (any of them).
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
>
> http://ocramius.github.com/
>
> On 22 February 2016 at 10:30, 'A K' via doctrine-user <
> [email protected] <javascript:>> wrote:
>
>> Hi Marco,
>>
>> Prefixing the @Table with schema name worked however because the schema
>> name is hardcoded, when I am running our integration tests the database
>> that is queried is live not the test one. Even though we do have in our
>> config_test.yml only test connections configured.
>>
>> For better understanding I've committed sample symfony application which
>> hopefully will demonstrate what I am trying to achieve.
>>
>> There was another issue I've had with the symfony mapping, but this might
>> be due to some symfony limitation. I had to put my Inventory entity in the
>> same bundle as my main Contact entity even though they both used different
>> connections.
>>
>> Is there something I am doing wrong? Is this possible at all?
>>
>> https://github.com/robotzero/doctrine_demo
>>
>> Thanks,
>> A.
>>
>> On Thursday, 18 February 2016 07:45:18 UTC, Marco Pivetta wrote:
>>>
>>>
>>> On 17 February 2016 at 22:26, 'A K' via doctrine-user <
>>> [email protected]> wrote:
>>>
>>>> Hi
>>>>
>>>> Is there a way to change the schema name in the annotation dynamically
>>>> depending on environment?
>>>>
>>>
>>> Not at runtime. You'd use a metadata on-load listener (
>>> http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#lifecycle-events
>>>
>>> ), and that can only be done before the ORM is ready for use. Also: you
>>> won't be able to cache metadata.
>>>
>>> For example we have standard production env that uses different database
>>>> names than test env, that prefixes all database names with _test. Using
>>>> your proposed annotation would cause all tests to use production database
>>>> names which we do not want to happen.
>>>>
>>>
>>> Uhm... Just use a test database connection? :|
>>>
>>>
>>> Marco Pivetta
>>>
>>> http://twitter.com/Ocramius
>>>
>>> http://ocramius.github.com/
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "doctrine-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/doctrine-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.