sqlboiler icon indicating copy to clipboard operation
sqlboiler copied to clipboard

test failure: Unable to upsert User: models: unable to upsert users: pq: INSERT with ON CONFLICT clause cannot be used with table that has INSERT or UPDATE rules

Open jkmpariab opened this issue 3 years ago • 2 comments

If you're having a generation problem please answer these questions before submitting your issue. Thanks!

What version of SQLBoiler are you using (sqlboiler --version)?

SQLBoiler v4.13.0

What is your database and version (eg. Postgresql 10)

Postgresql 14

If this happened at generation time what was the full SQLBoiler command you used to generate your models? (if not applicable leave blank)

If this happened at runtime what code produced the issue? (if not applicable leave blank)

What is the output of the command above with the -d flag added to it? (Provided you are comfortable sharing this, it contains a blueprint of your schema)

Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)

begin;

create table if not exists users(
    id serial primary key,
    name text not null
);

create table if not exists audits(
    id serial primary key,
    name text not null
);

create or replace rule update_rule as on update to users
do also insert into audits (name) values (new.name);

commit;

Further information. What did you do, what did you expect?

go test ./models expected test passes but failed

jkmpariab avatar Sep 11 '22 22:09 jkmpariab

It sounds like you're running into this: https://github.com/volatiletech/sqlboiler#why-are-the-auto-generated-tests-failing

parnic avatar Sep 19 '22 01:09 parnic

It sounds like you're running into this: https://github.com/volatiletech/sqlboiler#why-are-the-auto-generated-tests-failing

Definitely this is a Postgresql Rule functionality issue as there's no constraint in the provided reproducing sample sql!

jkmpariab avatar Sep 19 '22 13:09 jkmpariab

I don't think there is anything to be done here, so I am closing this issue.

stephenafamo avatar Sep 27 '22 11:09 stephenafamo

I don't think there is anything to be done here, so I am closing this issue.

I do't know what to say it is a sqlboiler issue I think you better leave this thread open until someone could suggest a workaround or let people talk about the issue

jkmpariab avatar Sep 27 '22 17:09 jkmpariab

Alright 🤷🏾‍♂️

stephenafamo avatar Sep 28 '22 06:09 stephenafamo

Alright 🤷🏾‍♂️

I mean atm i'm circumvent my problem using triggers instead but i'd be glad if i can go with rules as they looks more performant to me in this case.

So once again i tried to figure it out what is happening in test case that triggers this problem: It seems its an postgresql issue as with error message complaining and that problem is not related to sqlboiler if i should be honest.

What sqlboiler can/should do? Imo you should add configuration to remove some kind of tests that user is confident about.

Any more suggestion? I don't know more.

So feel free to close the thread. Good luck!

jkmpariab avatar Sep 28 '22 10:09 jkmpariab

The auto-generated tests are not very reliable and any PR to improve the quality of tests will be appreciated.

I'll close this in the meantime. Thank you.

stephenafamo avatar Oct 02 '22 15:10 stephenafamo