Problem on schema-tool:update function getListTableForeignKeysSQL #5706

Open
opened 2026-01-22 15:15:06 +01:00 by admin · 5 comments
Owner

Originally created by @alissonschneiderr on GitHub (Sep 21, 2017).

Originally assigned to: @alissonschneiderr on GitHub.

Hi, I'm having a problem while generating an sql dump, I'm getting the following error:

[Doctrine\DBAL\Exception\DriverException]
An exception occurred while executing 'SELECT quote_ident(r.conname) as conname, pg_catalog.pg_get_constraintdef(r.oid, true) as condef
FROM pg_catalog.pg_constraint r
WHERE r.conrelid =
(
SELECT c.oid
FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n
WHERE n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND c.relname = 'cc' AND n.nspname = ANY(string_to
_array((select replace(replace(setting,'"$user"',user),' ','') from pg_catalog.pg_settings where name = 'search_path'),',')) AND n.oid = c.relna
mespace
)
AND r.contype = 'f'':
SQLSTATE[21000]: Cardinality violation: 7 ERRO: mais de um registro foi retornado por uma subconsulta utilizada como uma expressão

[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[21000]: Cardinality violation: 7 ERRO: mais de um registro foi retornado por uma subconsulta utilizada como uma expressão

[PDOException]
SQLSTATE[21000]: Cardinality violation: 7 ERRO: mais de um registro foi retornado por uma subconsulta utilizada como uma expressão
orm:schema-tool:update [--complete] [--dump-sql] [-f|--force]

What can it be?

Sorry about english
Thanks

Originally created by @alissonschneiderr on GitHub (Sep 21, 2017). Originally assigned to: @alissonschneiderr on GitHub. Hi, I'm having a problem while generating an sql dump, I'm getting the following error: > [Doctrine\DBAL\Exception\DriverException] > An exception occurred while executing 'SELECT quote_ident(r.conname) as conname, pg_catalog.pg_get_constraintdef(r.oid, true) as condef > FROM pg_catalog.pg_constraint r > WHERE r.conrelid = > ( > SELECT c.oid > FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n > WHERE n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND c.relname = 'cc' AND n.nspname = ANY(string_to > _array((select replace(replace(setting,'"$user"',user),' ','') from pg_catalog.pg_settings where name = 'search_path'),',')) AND n.oid = c.relna > mespace > ) > AND r.contype = 'f'': > SQLSTATE[21000]: Cardinality violation: 7 ERRO: mais de um registro foi retornado por uma subconsulta utilizada como uma expressão > > [Doctrine\DBAL\Driver\PDOException] > SQLSTATE[21000]: Cardinality violation: 7 ERRO: mais de um registro foi retornado por uma subconsulta utilizada como uma expressão > > [PDOException] > SQLSTATE[21000]: Cardinality violation: 7 ERRO: mais de um registro foi retornado por uma subconsulta utilizada como uma expressão > orm:schema-tool:update [--complete] [--dump-sql] [-f|--force] What can it be? Sorry about english Thanks
Author
Owner

@Jean85 commented on GitHub (Sep 22, 2017):

Did you write the query yourself? The subquery is probably returning more than one result.

@Jean85 commented on GitHub (Sep 22, 2017): Did you write the query yourself? The subquery is probably returning more than one result.
Author
Owner

@alissonschneiderr commented on GitHub (Sep 22, 2017):

Yeah, I know, but is not my query, is doctrine query.

I think can be something in the database.

@alissonschneiderr commented on GitHub (Sep 22, 2017): Yeah, I know, but is not my query, is doctrine query. I think can be something in the database.
Author
Owner

@lcobucci commented on GitHub (Nov 26, 2017):

@alissonschneiderr could you please send us a failing test case that reproduces that behaviour? It would help us a lot to identify and fix the issue you're describing.

You can find examples on 388afb46d0/tests/Doctrine/Tests/ORM/Functional/Ticket

@lcobucci commented on GitHub (Nov 26, 2017): @alissonschneiderr could you please send us a failing test case that reproduces that behaviour? It would help us a lot to identify and fix the issue you're describing. You can find examples on https://github.com/doctrine/doctrine2/tree/388afb46d0cb3ed0c51332e8df0de9e942c2690b/tests/Doctrine/Tests/ORM/Functional/Ticket
Author
Owner

@alexislefebvre commented on GitHub (Jul 5, 2018):

We had a similar problem, and the error was due to an entity State, Doctrine created a table with name State and it generated the same error.

We solved it by specifying a name for the table: @ORM\Table(name="user_state").

@alexislefebvre commented on GitHub (Jul 5, 2018): We had a similar problem, and the error was due to an entity `State`, Doctrine created a table with name `State` and it generated the same error. We solved it by specifying a name for the table: `@ORM\Table(name="user_state")`.
Author
Owner

@alexislefebvre commented on GitHub (Jul 5, 2018):

I think that I found the root of the error, we used an entity with a table State, and this table was hosted in a PostgreSQL server in a Docker container.

That's probably why the subrequest returned 2 rows:

 SELECT c.oid                                                                                                                                                                      
                        FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n                                                                                                                             
                        WHERE n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND c.relname = 'state' AND n.nspname = ANY(string_to_array((select replace(replace(setting,'"$user"',us  
  er),' ','') from pg_catalog.pg_settings where name = 'search_path'),',')) AND n.oid = c.relnamespace
@alexislefebvre commented on GitHub (Jul 5, 2018): I think that I found the root of the error, we used an entity with a table `State`, and this table was hosted in a [PostgreSQL server in a Docker container](https://github.com/appropriate/docker-postgis). That's probably why the subrequest returned 2 rows: ```sql SELECT c.oid FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n WHERE n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND c.relname = 'state' AND n.nspname = ANY(string_to_array((select replace(replace(setting,'"$user"',us er),' ','') from pg_catalog.pg_settings where name = 'search_path'),',')) AND n.oid = c.relnamespace ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5706