v
v copied to clipboard
orm: add useful orm attributes
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.
Can you add a small example/test on how these will be used please?
Also, run v fmt -w vlib/v/gen/c/sql.v
Seems this one is just waiting for approval? @LouisSchmieder ?
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?"
Oh yeah there is an autocorrection. He should add it, but if nothing happens until the end of the week I will add one.
Hi guys, friendly reminder so we can finalize this @merlindiavova @LouisSchmieder.
If I've WiFi I'll add it this evening
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 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. 👍🏻
Ok, will do
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
Close/re-open to get a fresh CI run...
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)?
@walkingdevel Did you see this? Maybe we should merge/close this PR after all updated to ORM that were introduced since may 2022?