-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move schema part to the index #6226
Conversation
f944006
to
e7f76c2
Compare
This is prompted by doctrine/data-fixtures#452 , and now I think my PR looks so wrong that the issue must be somewhere else. |
Actually, reopening, because my tests don't involve the ORM and should really work. So maybe the fix is wrong, but I don't see how the tests are. |
e7f76c2
to
41e155c
Compare
41e155c
to
5be9228
Compare
'CREATE TABLE other_schema.foo (id INTEGER NOT NULL)', | ||
'CREATE INDEX other_schema.IDX_D9A8AD0DBF396750 ON foo (id)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not introduce this test. We do not care what the resulting SQL looks like as long as the functionality is covered by a test. Furthermore, this test is definitely not the source of truth about what the index name should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that the functional test would pass if the platform decided to create no index at all.
I agree about the generated name though. If we make assertions on the name if the index, we should explicitly declare a name for the index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I remove the unit test and modify the functional test to assert that an index does exist? If the platform decides not to create it, then introspecting the table won't show the index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I stand corrected. This fails for some reason 🤯 :
$onlineTable = $this->connection->createSchemaManager()->introspectTable('other.test_other_schema');
self::assertTrue($onlineTable->hasIndex('id'));
Doctrine\DBAL\Schema\Exception\TableDoesNotExist: There is no table with name "other.test_other_schema" in the schema.
I think there must be another bug. Or maybe it's just that it's not supported. If I use a separate connection, it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need to ensure that the index exists, we can introspect the schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I think I did exactly that:)
5be9228
to
719134e
Compare
In SQLite, creating an index in another schema is done by prepending the index name with the schema, while the table name must be unprefixed.
719134e
to
bc7afc1
Compare
Thank you @greg0ire! |
In SQLite, creating an index in another schema is done by prepending the
index name with the schema, while the table name must be unprefixed.
See https://www.sqlite.org/lang_createindex.html