Skip to content

DBAL-91: orm:convert-mapping SchemaException on Postgres reserved words #2152

Closed
doctrinebot opened this Issue Jan 10, 2011 · 15 comments

2 participants

@doctrinebot

Jira issue originally created by user emilw:

While execuiting

doctrine orm:convert-mapping --from-database yml /tmp/test.yml

I get presented an error

[Doctrine\DBAL\Schema\SchemaException]
Invalid index-name tablename"input"_idx given, has to be [a-zA-Z0-9]

The index "type" is quoted because this is a reserved word in Postgres. for example see the following definition:

FOREIGN KEY (something) REFERENCES somethings(id) ON UPDATE CASCADE
FOREIGN KEY (another) REFERENCES anothers(id) ON UPDATE CASCADE
FOREIGN KEY ("type") REFERENCES logtypes(id) ON UPDATE CASCADE

Only type will be quoted because it is a reserved word.

@doctrinebot

Comment created by @beberlei:

You have to quote with `` in Doctrine. That is translated to the underyling vendor quotation signs.

@doctrinebot

Comment created by emilw:

@benjamin this considers a mapping error from database (Postgres) to YAML through the doctrine commandline tool, I do not think your comment is relevant for this issue.

@doctrinebot

Comment created by @beberlei:

@Emil it is, are you quoting the reserved word in the YML file using `` ? DBAL has some logic to fix escaping in these cases.

@doctrinebot

Comment created by emilw:

@benjamin uhm, I might be baffled with the complexity of Doctrine or just plain wrong. But I'm trying to create a YML file from my database. How can I be making a mistake in the YML file with quotes?

The error message is presented because the Dcotrine ORM module tries to generate index names on columns, based on the database schema, but fails because the returned names (from the database schema) contain quotes (because they are reserved words).

@doctrinebot

Comment created by @beberlei:

Sorry, now i get it. I didnt relaize the usecase you were applying. Yes you are right :-)

@doctrinebot

Comment created by @beberlei:

Can you give me an Example Postgresql Schema with DDL SQL that produces this error?

@doctrinebot

Comment created by emilw:

These are the table creation for a test table which is able to reproduce the error.

@doctrinebot

Comment created by emilw:

I hope this is enough information. The attached SQL reproduces the following error:

doctrine orm:convert-mapping --from-database yml /tmp/test.yml

[Doctrine\DBAL\Schema\SchemaException]
Invalid index-name something"input"_idx given, has to be [a-zA-Z0-9]

orm:convert-mapping [--filter="..."] [--from-database] [--extend[="..."]] [--num-spaces[="..."]] -h -q -v -V -a -n command to-type dest-path

@doctrinebot

Comment created by @beberlei:

I can't reproduce it :-(

Can you run the command with --verbose ? Additionally in lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php can you var_dump() $metadata after line 119?

@doctrinebot

Comment created by @beberlei:

Ok i could reproduce it now. Input is not a keyword for me though, type also not. Coudl reproduce it with "table"

@doctrinebot

Comment created by @beberlei:

Ok, this is a DBAL issue.

@doctrinebot

Comment created by @beberlei:

This is fixed and will be included in 2.0.2

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label Dec 7, 2015
@beberlei beberlei was assigned by doctrinebot Dec 7, 2015
@doctrinebot doctrinebot added this to the 2.0.2 milestone Dec 7, 2015
@doctrinebot doctrinebot closed this Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.