Skip to content
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 split for SQLite CREATE INDEX only #6352

Open
wants to merge 1 commit into
base: 3.8.x
Choose a base branch
from

Conversation

mvorisek
Copy link
Contributor

@mvorisek mvorisek commented Apr 5, 2024

Q A
Type bug
Fixed issues n/a

Summary

SqlitePlatform::getCreatePrimaryKeySQL method must receive original table name, the split is intended for SQLite CREATE INDEX statement only.

@mvorisek mvorisek force-pushed the fix_primary_index_schema_split branch 4 times, most recently from c4a7206 to 0d1617e Compare April 5, 2024 19:15
@derrabus
Copy link
Member

derrabus commented Apr 7, 2024

There is no functional test included. We're making assertions purely on the generated SQL. Thus, the test does not really reproduce a bug that's fixed with this change.

Furthermore, you're testing an implementation detail: how the table name is passed from getCreateIndexSQL() to getCreatePrimaryKeySQL(). As a user of the DBAL library, I couldn't care less how the table is represented as long as my primary key is created correctly.

If I'm not mistaken, this change is supposed to fix a problem regarding the creation of primary keys on tables outside of the main schema. So, can we create a functional test that attempts exactly that?

Comment on lines 260 to 265
$indexDef = new Index('i', ['a', 'b']);
self::assertSame(
'CREATE INDEX main.i ON mytable (a, b)',
$this->platform->getCreateIndexSQL($indexDef, 'main.mytable'),
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method contains two test scenarios in a single test. Furthermore, this first scenario is green without your changes. It does not really cover anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have split the test into two.

The first test tests if expected SQL is generated when a table name with schema is given.

The second test tests if unmodified table/column is passed to SqlitePlatform::getCreatePrimaryKeySQL().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derrabus does this explanation makes sense to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derrabus can I please get your approval here?

@mvorisek mvorisek force-pushed the fix_primary_index_schema_split branch from d24cf43 to 20fbd75 Compare April 7, 2024 22:31
@mvorisek mvorisek requested a review from derrabus April 8, 2024 21:56
@derrabus
Copy link
Member

derrabus commented May 3, 2024

This comment hasn't been addressed as far as I can tell: #6352 (comment)

@mvorisek
Copy link
Contributor Author

mvorisek commented May 3, 2024

Function test (ie. test with DB) cannot be made as https://github.com/doctrine/dbal/blob/3.8.4/src/Platforms/SqlitePlatform.php#L995 always throws. Thus the test is coded to test the behaviour using overrided method.

@derrabus
Copy link
Member

derrabus commented May 3, 2024

If the scenario is an overridden platform, can't we run a functional test with an overridden platform?

@mvorisek
Copy link
Contributor Author

mvorisek commented May 3, 2024

Adding/altering primary key is not supported by SQLite using one SQL statement, thus I belive the current test cannot be coded better.

In anycase, we need to override the platform method to test this. This is what the current test does. It does not change the behaviour in sense of any currently generated SQL, but fixes what is passed to a public overridable method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants