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

[db]: Remove not supported column comments for SQLite #36803

Merged
merged 2 commits into from
Mar 2, 2023

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Feb 22, 2023

Summary

Some times column comments are used, e.g. to make clear an integer is used as a timestamp.
For SQLite column comments are not supported and migration that use column comments will not work (see linked comment above for an example).
Somehow it works when you have a clean install, then all migrations pass, but when executing single migrations they will fail.

This solves the problem by simply removing column comments when using SQLite.

Checklist

@susnux susnux added bug 3. to review Waiting for reviews labels Feb 22, 2023
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
@szaimen szaimen requested review from a team, ArtificialOwl, icewind1991 and blizzz and removed request for a team February 22, 2023 00:10
@szaimen szaimen added this to the Nextcloud 26 milestone Feb 22, 2023
@susnux susnux changed the title fix(DB): Strip not supported comments from SQLite columns [db]: Remove not supported column comments for SQLite Feb 22, 2023
@kesselb
Copy link
Contributor

kesselb commented Feb 22, 2023

Sounds weird.

Comments are supported by doctrine and sqlite: doctrine/dbal#819

@susnux
Copy link
Contributor Author

susnux commented Feb 22, 2023

Sounds weird.

Comments are supported by doctrine and sqlite: doctrine/dbal#819

The documentation does not list SQLite as supported:
https://www.doctrine-project.org/projects/doctrine-dbal/en/3.2/reference/schema-representation.html#common-options

Also SQL comments are not supported by SQLite (only inline comments within the schema).

How you can reproduce the error:

  1. Setup a nextcloud server using SQLite (e.g. docker image)
  2. Install and enable the forms app (version 3.1.0)
  3. Update forms to nextcloud/forms@3181423
  4. Try to run migrations and see error.

Or any other app you like and try to run a migration containing

$table->addColumn('foo', Types::INTEGER, [
	'notnull' => false,
	'default' => 0,
	'comment' => 'unix-timestamp',
]);

@skjnldsv skjnldsv mentioned this pull request Feb 23, 2023
@kesselb kesselb removed this from the Nextcloud 26 milestone Feb 23, 2023
@kesselb
Copy link
Contributor

kesselb commented Feb 24, 2023

Hi,

I created a bug report for doctrine/dbal: doctrine/dbal#5934.

Also SQL comments are not supported by SQLite (only inline comments within the schema).

'comment' => 'unix-timestamp', that's an inline comment within the schema ;)

Some times column comments are used, e.g. to make clear an integer is used as a timestamp.

I don't like the idea of having code in Nextcloud to remove comments on SQLite.

My recommendation is to remove the comments from the migrations because a comment in the code is a better place to document that a column should store a certain type of data.

@kesselb kesselb added this to the Nextcloud 26 milestone Feb 24, 2023
Copy link
Contributor

@kesselb kesselb left a comment

Choose a reason for hiding this comment

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

Seems valid, should work, still I don't like it ;)

Copy link
Member

@jotoeri jotoeri left a comment

Choose a reason for hiding this comment

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

Looks good to me. 👍

I'd rather have the comment at least when using mysql,... (and e.g. phpmyadmin), than not having it at all. To have code-comments is independently of course a good thing.

  • One could perhaps here add a comment to link to the dbal-issue. So once resolved one could re-check, if the comment-removal is still necessary.

@jotoeri
Copy link
Member

jotoeri commented Feb 26, 2023

/backport to stable25

@jotoeri
Copy link
Member

jotoeri commented Feb 26, 2023

/backport to stable24

@nickvergessen
Copy link
Member

Can we add a test to https://github.com/nextcloud/server/blob/master/tests/lib/DB/MigratorTest.php
So that it is ensured that SQLite keeps working?

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
@susnux
Copy link
Contributor Author

susnux commented Feb 28, 2023

Can we add a test so that it is ensured that SQLite keeps working?

@nickvergessen done :)

@blizzz blizzz merged commit 289fadf into master Mar 2, 2023
@blizzz blizzz deleted the fix/sqlite-comments branch March 2, 2023 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants