OCA / server-env

Tools to manage environment-dependent configuration
GNU Affero General Public License v3.0
57 stars 157 forks source link

[13.0] Remove required from tech_name mixin #69

Closed guewen closed 3 years ago

guewen commented 3 years ago

In some cases, we want to use a tech_name, but we do not use server environment on all the records, so tech_name should not be required.

guewen commented 3 years ago

ping @simahawk

guewen commented 3 years ago

The unique constraint considers NULL as distinct values, you can have several NULL values in records:

odoo@localhost:testdb> create table test (id integer, name varchar);
CREATE TABLE
Time: 0.011s
odoo@localhost:testdb> create unique index test_unique on test(name);
CREATE INDEX
Time: 0.007s
odoo@localhost:testdb> insert into test(id, name) values (1, 'foo');
INSERT 0 1
Time: 0.005s
odoo@localhost:testdb> insert into test(id, name) values (2, 'foo');
duplicate key value violates unique constraint "test_unique"
DETAIL:  Key (name)=(foo) already exists.

Time: 0.005s
odoo@localhost:testdb> insert into test(id, name) values (3, NULL);
INSERT 0 1
Time: 0.003s
odoo@localhost:testdb> insert into test(id, name) values (4, NULL);
INSERT 0 1
Time: 0.003s
guewen commented 3 years ago

oh we'll need an upgrade step to remove the constrain I think

We don't change the constraint, only required :) so an upgrade is enough (I tested to be sure).

simahawk commented 3 years ago

I tested to be sure)

great, tnx :)

simahawk commented 3 years ago

/ocabot merge patch

OCA-git-bot commented 3 years ago

What a great day to merge this nice PR. Let's do it! Prepared branch 13.0-ocabot-merge-pr-69-by-simahawk-bump-patch, awaiting test results.

OCA-git-bot commented 3 years ago

Congratulations, your PR was merged at cd3ff8a3ed0348b12ea1a67949bf5b632b887297. Thanks a lot for contributing to OCA. ❤️