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

Schema Generator touches nullable properties with each update #491

Closed
jasperroloff opened this issue Apr 19, 2020 · 3 comments · Fixed by #496
Closed

Schema Generator touches nullable properties with each update #491

jasperroloff opened this issue Apr 19, 2020 · 3 comments · Fixed by #496
Assignees
Labels
bug Something isn't working

Comments

@jasperroloff
Copy link

Describe the bug
When generating a migration or running a schema upgrade directly, the schema generator alters the nullable properties of the entity each time.

Stack trace
The generated schema update is the following (even if executed already):

set names utf8;
set foreign_key_checks = 0;

alter table `foo_entity` modify `nullable_string_property` varchar(255), modify `nullable_boolean_property` tinyint(1), modify `nullable_number_property` int(11);

set foreign_key_checks = 1;

To Reproduce
I've created a sample repository. Use ts-node src/main.ts to run.
https://github.com/jasperroloff/mikro-orm-nullable-issue

Expected behavior
Since the entity didn't change, the schema generator should generate an empty update (without the "alter table ..." statements).

Additional context
I discovered this behavior with both metadata providers: TsMorph, ReflectMetadata and with both database drivers: mysql, mariadb.

Versions

Dependency Version
node v13.13.0
typescript ^3.8.3
mikro-orm ^3.6.8
mariadb ^2.3.1
mysql2 ^2.1.0
ts-node ^8.8.2

(see package.json in sample repo)

@jasperroloff jasperroloff added the bug Something isn't working label Apr 19, 2020
@B4nan
Copy link
Member

B4nan commented Apr 19, 2020

Well it does not produce any additional queries for me. What version of MySQL are you using (not the driver)? Maybe you use MySQL 8?

edit: it works ok for me even with MySQL 8. also tried to run it in the repo you provided, same result.

@jasperroloff
Copy link
Author

jasperroloff commented Apr 19, 2020

Hi, thanks for your reply.

I am using MariaDB, select version() returns the following: 10.4.11-MariaDB.

Edit: I just tested it with MySQL 8.0.19 as server, I am getting the same result as you did (everything works as it should).
So it looks like this problem does only happen with MariaDB servers.

@B4nan
Copy link
Member

B4nan commented Apr 19, 2020

Interesting, tried it with mariadb 10.1 first and it passed, but with 10.4 it does behave like you described.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants