v icon indicating copy to clipboard operation
v copied to clipboard

orm: add useful orm attributes

Open merlindiavova opened this issue 3 years ago • 13 comments

Currently there is no way to skip/remove fields that the DB auto generates values for. This includes id, uuid and timestamp. In the case of uuid and timestamp the pg module seg faults.

This PR addresses this shortcoming by proposing 3 new useful attributes:

  • skip_insert - The field should be skipped/removed for all SQL insert operations.
  • skip_update - The field should be skipped/removed for all SQL update operations.
  • skip_insert_update - alias for both above options.

merlindiavova avatar May 09 '22 18:05 merlindiavova

Can you add a small example/test on how these will be used please?

spytheman avatar May 10 '22 12:05 spytheman

Also, run v fmt -w vlib/v/gen/c/sql.v

spytheman avatar May 10 '22 12:05 spytheman

Seems this one is just waiting for approval? @LouisSchmieder ?

JalonSolov avatar Jun 18 '22 01:06 JalonSolov

Hey @LouisSchmieder were you going to add a test or should @merlindiavova give it a try? I am thinking you must have meant "I'll" instead of "old?"

ylluminate avatar Jun 20 '22 20:06 ylluminate

Oh yeah there is an autocorrection. He should add it, but if nothing happens until the end of the week I will add one.

LouisSchmieder avatar Jun 20 '22 22:06 LouisSchmieder

Hi guys, friendly reminder so we can finalize this @merlindiavova @LouisSchmieder.

ylluminate avatar Jun 30 '22 16:06 ylluminate

If I've WiFi I'll add it this evening

LouisSchmieder avatar Jun 30 '22 16:06 LouisSchmieder

Hi all,

Sorry for delay in getting to this. Work life happened!

Have the tests been done? If not I can get to them today

merlindiavova avatar Jul 09 '22 05:07 merlindiavova

@merlindiavova I don't think @LouisSchmieder has had a chance yet since we don't see the commits here, so I'd say go for it. 👍🏻

ylluminate avatar Jul 09 '22 06:07 ylluminate

Ok, will do

merlindiavova avatar Jul 09 '22 07:07 merlindiavova

I have added some tests. It seems there are some underlying issues with the ORM which needs to get fixed before I can write more testcases. I will raise separate issues and hopefully help get some PRs up

merlindiavova avatar Jul 09 '22 14:07 merlindiavova

Close/re-open to get a fresh CI run...

JalonSolov avatar Oct 15 '22 00:10 JalonSolov

Looks like all the failures are related to trying to test against a postgresql database.

@merlindiavova are you able to make the suggested changes to the test(s)?

JalonSolov avatar Oct 15 '22 12:10 JalonSolov

@walkingdevel Did you see this? Maybe we should merge/close this PR after all updated to ORM that were introduced since may 2022?

ArtemkaKun avatar May 26 '23 17:05 ArtemkaKun